Move to use filtered packages/services/clients
Instead of passing a huge dict lets filter the services so that only the required packages are installed (in one command). Additionally, we can perform a similar filtering for the services and clients that are used as a part of the ceph_components var. Change-Id: I64cced1bf82c9d7b4368873eff524603b91162c8
This commit is contained in:
parent
38ba631b75
commit
b1cf342b27
@ -14,11 +14,8 @@
|
||||
|
||||
- name: Restart os services
|
||||
service:
|
||||
name: "{{ item.1 }}"
|
||||
name: "{{ item }}"
|
||||
state: restarted
|
||||
with_subelements:
|
||||
- "{{ ceph_components + ceph_extra_components }}"
|
||||
- service
|
||||
when: inventory_hostname in groups[item.0.component]
|
||||
with_items: "{{ ceph_client_filtered_services }}"
|
||||
failed_when: false
|
||||
|
||||
|
@ -20,17 +20,8 @@
|
||||
# the first get makes sure the client exists, so the second only runs when it
|
||||
# exists, the trick is the different output of both, the second has the right
|
||||
# output to put in a keyring; ceph admin should have already created the user
|
||||
shell: ceph auth get client.{{ item.1 }} >/dev/null && ceph auth get-or-create client.{{ item.1 }}
|
||||
with_subelements:
|
||||
- "{{ ceph_components + ceph_extra_components }}"
|
||||
- client
|
||||
when:
|
||||
- inventory_hostname in groups[item.0.component]
|
||||
- (item.0.component != 'cinder_backup' or
|
||||
((cinder_service_backup_program_enabled is defined and
|
||||
cinder_service_backup_program_enabled | bool) and
|
||||
(cinder_service_backup_driver is defined and
|
||||
cinder_service_backup_driver == 'cinder.backup.drivers.ceph')))
|
||||
shell: ceph auth get client.{{ item }} >/dev/null && ceph auth get-or-create client.{{ item }}
|
||||
with_items: "{{ ceph_client_filtered_clients }}"
|
||||
changed_when: false
|
||||
delegate_to: '{{ ceph_mon_host }}'
|
||||
register: ceph_client_keyrings
|
||||
@ -59,7 +50,7 @@
|
||||
# ceph get-or-create ... ... -o file?
|
||||
template:
|
||||
src: ceph.client.keyring.j2
|
||||
dest: /etc/ceph/ceph.client.{{ item.item.1 }}.keyring
|
||||
dest: /etc/ceph/ceph.client.{{ item.item }}.keyring
|
||||
backup: true
|
||||
owner: root
|
||||
# TODO
|
||||
@ -74,7 +65,6 @@
|
||||
with_items: "{{ ceph_client_keyrings.results }}"
|
||||
when:
|
||||
- not item | skipped
|
||||
- inventory_hostname in groups[item.item.0.component]
|
||||
notify:
|
||||
- Restart os services
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
- name: Install ceph packages
|
||||
package:
|
||||
name: '{{ item.1 }}'
|
||||
name: '{{ ceph_client_filtered_packages }}'
|
||||
state: "{{ ceph_client_package_state }}"
|
||||
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
|
||||
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
|
||||
@ -23,10 +23,5 @@
|
||||
until: install_packages|success
|
||||
retries: 5
|
||||
delay: 2
|
||||
with_subelements:
|
||||
- "{{ ceph_components + ceph_extra_components }}"
|
||||
- package
|
||||
when:
|
||||
- inventory_hostname in groups[item.0.component]
|
||||
notify:
|
||||
- Restart os services
|
||||
|
@ -56,3 +56,42 @@ ceph_extra_components: []
|
||||
# client:
|
||||
# - '{{ gnocchi_ceph_client }}'
|
||||
# service: '{{ ceph_gnocchi_service_names }}'
|
||||
|
||||
ceph_client_filtered_packages: |-
|
||||
{% set packages = [] %}
|
||||
{% for comp in (ceph_components + ceph_extra_components) %}
|
||||
{% if comp.component in group_names %}
|
||||
{% for pkg_name in comp.package %}
|
||||
{% if pkg_name not in packages %}
|
||||
{% set _ = packages.apend(pkg_name) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ packages }}
|
||||
|
||||
ceph_client_filtered_services: |-
|
||||
{% set services = [] %}
|
||||
{% for comp in (ceph_components + ceph_extra_components) %}
|
||||
{% if comp.component in group_names %}
|
||||
{% set _ = services.append(comp.service) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ service }}
|
||||
|
||||
ceph_client_filtered_clients: |-
|
||||
{% set clients = [] %}
|
||||
{% for comp in (ceph_components + ceph_extra_components) %}
|
||||
{% if comp.component in group_names %}
|
||||
{% if ((comp.component != 'cinder_backup') or
|
||||
((cinder_service_backup_program_enabled is defined and
|
||||
cinder_service_backup_program_enabled | bool) and
|
||||
(cinder_service_backup_driver is defined and
|
||||
cinder_service_backup_driver == 'cinder.backup.drivers.ceph'))) %}
|
||||
{% for client in comp.client %}
|
||||
{% _ = clients.append(client)
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ clients }}
|
||||
|
Loading…
Reference in New Issue
Block a user