- hosts: localhost gather_facts: false tasks: - name: Read in cloud config os_client_config: - name: Add fake host for each cloud region so we can parallelize add_host: name: "{{ item.name }}-{{ item.region_name }}" ansible_host: localhost ansible_connection: local groups: clouds cloud: "{{ item.name }}" region_name: "{{ item.region_name }}" with_items: "{{ openstack.clouds }}" - hosts: clouds gather_facts: false tasks: - name: Upload ssh public key os_keypair: public_key_file: "{{ ansible_user_dir }}/.ssh/id_rsa.pub" name: "three_minute_demo" cloud: "{{ cloud }}" region_name: "{{ region_name }}" - name: Add wide-open security group os_security_group: name: three-minute-demo-group description: Open security group - name: Add rules to group os_security_group_rules: ethertype: "{{ item.ethertype }}" remote_group: "{{ item.remote_group|default(omit) }}" remote_ip_prefix: "{{ item.remote_ip_prefix|default(omit) }}" security_group: three-minute-demo-group with_items: - ethertype: IPv4 remote_group: default state: absent - ethertype: IPv6 remote_group: default state: absent - ethertype: IPv4 remote_ip_prefix: 0.0.0.0/0 - ethertype: IPv6 remote_ip_prefix: ::/0 - name: Create a small VM os_server: auto_ip: true key_name: three_minute_demo name: three_minute_demo_server cloud: "{{ cloud }}" region_name: "{{ region_name }}" wait: true register: created_server - name: Add VM to inventory add_host: name: "{{ cloud }}.{{ region_name }}.demo" ansible_host: "{{ created_server.interface_ip }}" group: demo_servers - name: Print Interface IP for created server debug: var: created_server.interface_ip - hosts: demo_servers tasks: - name: Install webserver package: name: apache2 state: installed become: yes - name: Write content template: src: templates/setup.json.j2 dest: /var/www/html/setup.json become: yes - name: Ensure webserver is running service: name: apache2 state: started become: yes - name: Get Info from Server uri: url: "http://{{ ansible_host }}/setup.json" register: server_info delegate_to: localhost - name: Print FQDN information about host debug: var: server_info.json.ansible_fqdn