diff --git a/tasks/cleanup.yml b/tasks/cleanup.yml index f08b0eda11d5bdda26cf900ea6d3dac533f3456b..3ee0c7d754e462ce3db729971045c04f8ee7fee4 100644 --- a/tasks/cleanup.yml +++ b/tasks/cleanup.yml @@ -3,26 +3,26 @@ - name: Remove host from known_hosts known_hosts: - name="{{ item }}" - state="absent" + name: '{{ item }}' + state: absent with_items: - {{ static_ipv4|default(false) }} - {{ host }} - name: Remove host from hosts file 1 lineinfile: - dest=/etc/hosts - regexp='{{ item }}' - state=absent + dest: /etc/hosts + regexp: '{{ item }}' + state: absent become: yes with_items: - ^{{ static_ipv4|default(false) }} - name: Remove host from hosts file 2 lineinfile: - dest=/etc/hosts - regexp='{{ item }}' - state=absent + dest: /etc/hosts + regexp: '{{ item }}' + state: absent become: yes with_items: - .* {{ host }}$ diff --git a/tasks/ec2/inithost.yml b/tasks/ec2/inithost.yml index 48caca96c437d78cba003d912a299de29114491d..8499ec69042e09bf172ac7f91a7195dd915934b2 100644 --- a/tasks/ec2/inithost.yml +++ b/tasks/ec2/inithost.yml @@ -6,7 +6,10 @@ - name: Create the new instance ec2: - instance_tags: {"Name":"Ansible-Host-{{ host }}","AnsibleHost":"{{ host }}","AnsibleGroups":"{{ initgroups }}"} + instance_tags: + Name: Ansible-Host-{{ host }} + AnsibleHost: '{{ host }}' + AnsibleGroups: '{{ initgroups }}' assign_public_ip: yes group_id: "{{ ec2_group_id }}" key_name: "{{ ec2_key_name }}" @@ -28,15 +31,15 @@ - block: - - name: Associate an elastic IP with the new instance - ec2_eip: - device_id: "{{ item }}" - public_ip: '{{ inithostip }}' - region: "{{ ec2_region }}" - state: present - with_items: '{{ ec2.instance_ids }}' + - name: Associate an elastic IP with the new instance + ec2_eip: + device_id: "{{ item }}" + public_ip: '{{ inithostip }}' + region: "{{ ec2_region }}" + state: present + with_items: '{{ ec2.instance_ids }}' - - import_tasks: inithostip.yml hostip='{{ inithostip }}' + - import_tasks: inithostip.yml hostip='{{ inithostip }}' when: inithostip is defined diff --git a/tasks/ec2/inithostip.yml b/tasks/ec2/inithostip.yml index f2b75b46200e903f21e7d964e2a87217845f1162..de71cb6a161b95048cbd4dfd97a516e0ac2c084d 100644 --- a/tasks/ec2/inithostip.yml +++ b/tasks/ec2/inithostip.yml @@ -3,14 +3,14 @@ - name: Add new instance(s) to the inventory add_host: - hostname="{{ host }}" - static_ipv4="{{ hostip }}" - groups="{{ initgroups }}" + hostname: '{{ host }}' + static_ipv4: '{{ hostip }}' + groups: '{{ initgroups }}' - name: Waiting for SSH service becoming available wait_for: - host="{{ hostip }}" - port=22 - delay=10 - timeout=120 - state=present + host: '{{ hostip }}' + port: 22 + delay: 10 + timeout: 120 + state: present diff --git a/tasks/main.yml b/tasks/main.yml index 1b36010cac40debe7d3205386cecd6b4df6ceaf5..8f4d1910c92f99b0ac9247ec7deface06fcd4e56 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,8 +9,8 @@ - block: - - import_tasks: "{{ cloud|default('none') }}/{{ mode }}.yml" + - import_tasks: "{{ cloud|default('none') }}/{{ mode }}.yml" - - import_tasks: "{{ mode }}.yml" + - import_tasks: "{{ mode }}.yml" when: not excluded_roles or "cloud" not in excluded_roles