OpenStack: Cloud management with Ansible

Ansible OpenStack modules
https://docs.ansible.com/ansible/latest/search.html?q=os_

Ansible OpenStack module repository
https://github.com/ansible/ansible/tree/devel/lib/ansible/modules/cloud/openstack

# Fix; To utilize this module, the installed version ofthe shade library MUST be >=1.8.0
wget http://mirrors.kernel.org/ubuntu/pool/universe/p/python-shade/python-shade_1.30.0-2_all.deb -O /tmp/python-shade_1.30.0-2_all.deb
sudo dpkg -i /tmp/python-shade_1.30.0-2_all.deb

Create OpenStack VM with Ansible

    - name: Create VM
      openstack.cloud.server:
        cloud: "{{ os_cloud }}"
        name: "{{ os_server_name }}"
        image: "{{ os_server_image }}"
        key_name: "{{ os_server_keypair }}"
        flavor: "{{ os_server_flavor }}"
        nics:
          - port-name: "{{ item }}_{{ os_network }}"
        auto_floating_ip: yes
        availability_zone: "{{ os_server_availability_zone }}"
        meta:
          sysadmin: "{{ os_sysadmin }}"
        userdata: |
          #cloud-config
          package_upgrade: true
          packages:
            - curl
          users:
            - name: foo
              sudo: ALL=(ALL) NOPASSWD:ALL
              shell: /bin/bash
              ssh_authorized_keys:
                - "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
              ssh_import_id:
                - gh:foo
                - gh:bar