40 lines
1.6 KiB
YAML
40 lines
1.6 KiB
YAML
|
|
---
|
||
|
|
# Client openstack de Kolla, compte admin (clouds.yaml généré par post-deploy).
|
||
|
|
- name: lire les gabarits existants
|
||
|
|
ansible.builtin.command: openstack flavor list -f json
|
||
|
|
environment: &os_admin
|
||
|
|
PATH: "/opt/kolla-venv/bin:{{ ansible_env.PATH }}"
|
||
|
|
OS_CLIENT_CONFIG_FILE: /etc/kolla/clouds.yaml
|
||
|
|
OS_CLOUD: kolla-admin
|
||
|
|
register: openstack_gabarits_existants
|
||
|
|
changed_when: false
|
||
|
|
|
||
|
|
- name: créer les gabarits manquants
|
||
|
|
ansible.builtin.command: >-
|
||
|
|
openstack flavor create --public --ram {{ item.ram }} --vcpus {{ item.vcpus }}
|
||
|
|
--disk {{ item.disque }} {{ item.nom }}
|
||
|
|
environment: *os_admin
|
||
|
|
loop: "{{ openstack_gabarits }}"
|
||
|
|
when: item.nom not in (openstack_gabarits_existants.stdout | from_json | map(attribute='Name') | list)
|
||
|
|
|
||
|
|
- name: lire le quota de calcul du projet
|
||
|
|
ansible.builtin.command: openstack quota show --compute {{ openstack_projet }} -f json
|
||
|
|
environment: *os_admin
|
||
|
|
register: openstack_quota_brut
|
||
|
|
changed_when: false
|
||
|
|
|
||
|
|
- name: régler le quota de calcul du projet
|
||
|
|
ansible.builtin.command: >-
|
||
|
|
openstack quota set --instances {{ openstack_projet_quota.instances }}
|
||
|
|
--cores {{ openstack_projet_quota.cores }} --ram {{ openstack_projet_quota.ram }}
|
||
|
|
{{ openstack_projet }}
|
||
|
|
environment: *os_admin
|
||
|
|
vars:
|
||
|
|
openstack_quota_actuel: >-
|
||
|
|
{{ dict(openstack_quota_brut.stdout | from_json | map(attribute='Resource') |
|
||
|
|
zip(openstack_quota_brut.stdout | from_json | map(attribute='Limit'))) }}
|
||
|
|
when: >-
|
||
|
|
openstack_quota_actuel.instances != openstack_projet_quota.instances or
|
||
|
|
openstack_quota_actuel.cores != openstack_projet_quota.cores or
|
||
|
|
openstack_quota_actuel.ram != openstack_projet_quota.ram
|