|
| 1 | +--- |
| 2 | +- name: Ensure magnum client is installed |
| 3 | + ansible.builtin.pip: |
| 4 | + name: python-magnumclient |
| 5 | + state: present |
| 6 | + virtualenv: "{{ os_container_clusters_venv or omit }}" |
| 7 | + become: "{{ os_container_clusters_venv == None }}" |
| 8 | + |
| 9 | +- name: Set a fact about the Ansible python interpreter |
| 10 | + ansible.builtin.set_fact: |
| 11 | + old_ansible_python_interpreter: "{{ ansible_python_interpreter | default('/usr/bin/python3') }}" |
| 12 | + |
| 13 | +- name: Ensure container cluster templates exist |
| 14 | + vars: |
| 15 | + ansible_python_interpreter: "{{ os_container_clusters_venv ~ '/bin/python' if os_container_clusters_venv != None else old_ansible_python_interpreter }}" |
| 16 | + openstack.cloud.coe_cluster_template: |
| 17 | + auth: "{{ os_container_clusters_auth }}" |
| 18 | + auth_type: "{{ os_container_clusters_auth_type }}" |
| 19 | + cacert: "{{ os_container_clusters_cacert | default(omit) }}" |
| 20 | + interface: "{{ os_container_clusters_interface | default(omit, true) }}" |
| 21 | + labels: "{{ item.labels | default(omit) }}" |
| 22 | + external_network_id: "{{ item.external_network_id | default(undef(hint='You must provide an external network')) }}" |
| 23 | + master_flavor_id: "{{ item.master_flavor | default(undef(hint='You must provide a master flavor')) }}" |
| 24 | + flavor_id: "{{ item.flavor | default(undef(hint='You must provide a flavor')) }}" |
| 25 | + image_id: "{{ item.image | default(undef(hint='You must provide an image')) }}" |
| 26 | + name: "{{ item.name | default(undef(hint='You must provide a name')) }}" |
| 27 | + coe: "{{ item.coe | default(undef(hint='You must provide a coe')) }}" |
| 28 | + network_driver: "{{ item.network_driver | default(omit) }}" |
| 29 | + master_lb_enabled: "{{ item.master_lb_enabled | default(True) | bool }}" |
| 30 | + floating_ip_enabled: "{{ item.floating_ip_enabled | default(True) | bool }}" |
| 31 | + dns_nameserver: "{{ item.dns_nameserver | default(omit) }}" |
| 32 | + public: "{{ item.public | default(os_container_clusters_public) | bool }}" |
| 33 | + docker_volume_size: "{{ item.docker_volume_size | default(omit) }}" |
| 34 | + fixed_network: "{{ item.fixed_network | default(omit) }}" |
| 35 | + fixed_subnet: "{{ item.fixed_subnet | default(omit) }}" |
| 36 | + registry_enabled: "{{ item.registry_enabled | default(omit) }}" |
| 37 | + tls_disabled: "{{ item.tls_disabled | default(omit) }}" |
| 38 | + keypair_id: "{{ item.keypair_id | default(omit) }}" |
| 39 | + volume_driver: "{{ item.volume_driver | default(omit) }}" |
| 40 | + http_proxy: "{{ item.http_proxy | default(omit) }}" |
| 41 | + https_proxy: "{{ item.https_proxy | default(omit) }}" |
| 42 | + no_proxy: "{{ item.no_proxy | default(omit) }}" |
| 43 | + state: "{{ item.state | default(omit) }}" |
| 44 | + with_items: "{{ os_container_clusters_templates }}" |
| 45 | + |
| 46 | +# NOTE: The coe_cluster_template module does not currently support setting the |
| 47 | +# hidden parameter. |
| 48 | +- name: Hide cluster templates if specified |
| 49 | + ansible.builtin.command: > |
| 50 | + {{ os_container_clusters_venv ~ '/bin/' if os_container_clusters_venv else '' }}openstack |
| 51 | + {% for auth_name, auth_value in os_container_clusters_auth.items() %} |
| 52 | + --os-{{ auth_name | replace('_', '-') }}='{{ auth_value }}' |
| 53 | + {% endfor %} |
| 54 | + {% if os_container_clusters_cacert is defined %} |
| 55 | + --os-cacert {{ os_container_clusters_cacert }} |
| 56 | + {% endif %} |
| 57 | + --os-interface=public |
| 58 | + coe cluster template update {{ item.name }} replace hidden=True |
| 59 | + with_items: "{{ os_container_clusters_templates }}" |
| 60 | + when: item.is_hidden | default(os_container_clusters_templates_hide) | bool |
| 61 | + changed_when: true |
0 commit comments