| | |
| | | label: "{{item.tags.internaldns | default(item.private_dns_name)}}" |
| | | ignore_errors: yes |
| | | |
| | | - add_host: |
| | | - name: Add Linux hosts |
| | | add_host: |
| | | name: "{{item.tags.internaldns | default(item.private_dns_name)}}" |
| | | shortname: "{{item.tags.Name | default(item.private_dns_name)}}" |
| | | groups: |
| | |
| | | public_dns_name: "{{item['public_dns_name']}}" |
| | | private_dns_name: "{{item['private_dns_name']}}" |
| | | private_ip_address: "{{item['private_ip_address']}}" |
| | | public_ip_address: "{{item['public_ip_address']}}" |
| | | public_ip_address: "{{item['public_ip_address'] | d('') }}" |
| | | placement: "{{item['placement']['availability_zone']}}" |
| | | image_id: "{{item['image_id']}}" |
| | | ansible_ssh_extra_args: "-o StrictHostKeyChecking=no" |
| | | ansible_python_interpreter: "{{ item.tags.ansible_python_interpreter | default(omit) }}" |
| | | bastion: "{{ local_bastion | default('') }}" |
| | | when: item.state.name != 'terminated' |
| | | ostype: "{{item.tags.ostype | default('linux')}}" |
| | | instance_name: "{{item.tags.instance_name | d('') }}" |
| | | when: |
| | | - item.state.name != 'terminated' |
| | | - item.tags.ostype | d('linux') == 'linux' |
| | | with_items: "{{ec2_facts['instances']}}" |
| | | loop_control: |
| | | label: "{{item.tags.internaldns | default(item.private_dns_name)}}" |
| | | tags: |
| | | - create_inventory |
| | | - must |
| | | |
| | | - name: Add Windows hosts - winrm |
| | | add_host: |
| | | name: "{{item.tags.internaldns | default(item.private_dns_name)}}" |
| | | shortname: "{{item.tags.Name | default(item.private_dns_name)}}" |
| | | groups: |
| | | - "tag_Project_{{stack_tag}}" |
| | | - "tag_{{stack_tag}}_{{item['tags'][project_tag] | default('unknowns')}}" |
| | | - "tag_{{stack_tag}}_ostype_{{item['tags'][project_tag_ostype] | default('unknown')}}" |
| | | - "{{item.tags.ostype | default('unknowns')}}" |
| | | - "{{item['tags'][project_tag_ostype] | default('unknowns')}}" |
| | | - "{{ 'newnodes' if (item.tags.newnode|d()|bool) else 'all'}}" |
| | | ansible_user: Administrator |
| | | remote_user: Administrator |
| | | ansible_connection: winrm |
| | | ansible_password: "{{ hostvars['localhost'].windows_password | default(hostvars['localhost'].generated_windows_password) }}" |
| | | ansible_port: 5986 |
| | | ansible_winrm_server_cert_validation: ignore |
| | | key_name: "{{item['key_name']}}" |
| | | state: "{{item['state']}}" |
| | | internaldns: "{{item.tags.internaldns | default(item.private_dns_name)}}" |
| | | isolated: "{{item.tags.isolated | default(false)}}" |
| | | instance_id: "{{ item.instance_id }}" |
| | | region: "{{ aws_region_final | default(aws_region) | default(region) | default('us-east-1')}}" |
| | | public_dns_name: "{{item['public_dns_name']}}" |
| | | private_dns_name: "{{item['private_dns_name']}}" |
| | | private_ip_address: "{{item['private_ip_address']}}" |
| | | public_ip_address: "{{item['public_ip_address'] | d('') }}" |
| | | placement: "{{item['placement']['availability_zone']}}" |
| | | image_id: "{{item['image_id']}}" |
| | | bastion: "{{ local_bastion | default('') }}" |
| | | ostype: windows |
| | | instance_name: "{{item.tags.instance_name | d('') }}" |
| | | when: |
| | | - item.state.name != 'terminated' |
| | | - item.tags.ostype | d('linux') == 'windows' |
| | | - win_connect_method == 'winrm' |
| | | with_items: "{{ec2_facts['instances']}}" |
| | | loop_control: |
| | | label: "{{item.tags.internaldns | default(item.private_dns_name)}}" |
| | | tags: |
| | | - create_inventory |
| | | - must |
| | | |
| | | - name: Add Windows Hosts - psrp |
| | | add_host: |
| | | name: "{{item.tags.internaldns | default(item.private_dns_name)}}" |
| | | shortname: "{{item.tags.Name | default(item.private_dns_name)}}" |
| | | groups: |
| | | - "tag_Project_{{stack_tag}}" |
| | | - "tag_{{stack_tag}}_{{item['tags'][project_tag] | default('unknowns')}}" |
| | | - "tag_{{stack_tag}}_ostype_{{item['tags'][project_tag_ostype] | default('unknown')}}" |
| | | - "{{item.tags.ostype | default('unknowns')}}" |
| | | - "{{item['tags'][project_tag_ostype] | default('unknowns')}}" |
| | | - "{{ 'newnodes' if (item.tags.newnode|d()|bool) else 'all'}}" |
| | | ansible_user: Administrator |
| | | remote_user: Administrator |
| | | ansible_connection: psrp |
| | | ansible_password: "{{ hostvars['localhost'].windows_password | default(hostvars['localhost'].generated_windows_password) }}" |
| | | ansible_psrp_protocol: https |
| | | ansible_psrp_auth: basic |
| | | ansible_psrp_cert_validation: ignore |
| | | ansible_psrp_proxy: "socks5h://localhost:{{psrp_socks_port}}" |
| | | key_name: "{{item['key_name']}}" |
| | | state: "{{item['state']}}" |
| | | internaldns: "{{item.tags.internaldns | default(item.private_dns_name)}}" |
| | | isolated: "{{item.tags.isolated | default(false)}}" |
| | | instance_id: "{{ item.instance_id }}" |
| | | region: "{{ aws_region_final | default(aws_region) | default(region) | default('us-east-1')}}" |
| | | public_dns_name: "{{item['public_dns_name']}}" |
| | | private_dns_name: "{{item['private_dns_name']}}" |
| | | private_ip_address: "{{item['private_ip_address']}}" |
| | | public_ip_address: "{{item['public_ip_address'] | d('') }}" |
| | | placement: "{{item['placement']['availability_zone']}}" |
| | | image_id: "{{item['image_id']}}" |
| | | bastion: "{{ local_bastion | default('') }}" |
| | | ostype: windows |
| | | instance_name: "{{item.tags.instance_name | d('') }}" |
| | | when: |
| | | - item.state.name != 'terminated' |
| | | - item.tags.ostype | d('linux') == 'windows' |
| | | - win_connect_method == 'psrp' |
| | | with_items: "{{ec2_facts['instances']}}" |
| | | loop_control: |
| | | label: "{{item.tags.internaldns | default(item.private_dns_name)}}" |