Jim Rigsbee
2020-02-12 2f15941d40fc11d9042d0658ec2086a85a150a61
ansible/cloud_providers/ec2_infrastructure_deployment.yml
@@ -62,6 +62,17 @@
      import_role:
        name: infra-common-ssh-config-generate
    - name: Stop SSH/Socks proxy for Windows proxying through bastion
      shell: |
        ssh -i {{ ssh_key | default(infra_ssh_key) | default(ansible_ssh_private_key_file) | default(default_key_name)}} -o "ControlPath=~/.ssh/cp/ssh-%r@%h:%p" -O exit -p 22 {{hostvars[bastion_hostname].ansible_user}}@{{hostvars[bastion_hostname].public_ip_address}}
      when: win_connect_method | d('winrm') == 'psrp'
      ignore_errors: true
    - name: Start a SSH/Socks proxy for Windows proxying through bastion
      shell: |
        mkdir -p ~/.ssh/cp
        ssh -i {{ ssh_key | default(infra_ssh_key) | default(ansible_ssh_private_key_file) | default(default_key_name)}} -o "ControlMaster=auto" -o "ControlPersist=no" -o "ControlPath=~/.ssh/cp/ssh-%r@%h:%p" -o "StrictHostKeyChecking=no" -CfNq -D 127.0.0.1:{{psrp_socks_port}} -p 22 {{hostvars[bastion_hostname].ansible_user}}@{{hostvars[bastion_hostname].public_ip_address}}
      when: win_connect_method | d('winrm') == 'psrp'
# include global vars again, this time for all hosts now that the inventory is built
- import_playbook: ../include_vars.yml
  tags:
@@ -104,20 +115,7 @@
    - step001
    - step001.4
  tasks:
    - name: set facts for remote access
      tags:
        - create_inventory
      set_fact:
        ansible_become: false
        ansible_connection: winrm
        ansible_host: "{{ public_dns_name }}"
        ansible_password: "{{ hostvars['localhost'].windows_password | default(hostvars['localhost'].generated_windows_password) }}"
        ansible_port: 5986
        ansible_user: Administrator
        ansible_winrm_server_cert_validation: ignore
        aws_region_final: "{{hostvars['localhost'].aws_region_final}}"
    - name: Run infra-ec2-wait_for_linux_hosts Role
    - name: Run infra-ec2-wait_for_windows_hosts Role
      import_role:
        name: infra-ec2-wait_for_windows_hosts