Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing usage of group 'all' by dynamic generated group containing all ceph groups #247

Open
rppietrzak opened this issue Sep 24, 2019 · 1 comment · May be fixed by #248
Open

Replacing usage of group 'all' by dynamic generated group containing all ceph groups #247

rppietrzak opened this issue Sep 24, 2019 · 1 comment · May be fixed by #248

Comments

@rppietrzak
Copy link

rppietrzak commented Sep 24, 2019

Scenario:

  • using the inventory which contains more groups that might be not directly part of ceph deployment

Result:

  • the prometheus.yml templated on the host will have additional non-ceph host in the node section
  • if the non-ceph host will be not available for some reason the cephmetrics deployment will fail on the first gather_facts playbook

Those are caused by the line the https://github.com/ceph/cephmetrics/blob/master/ansible/roles/ceph-prometheus/templates/prometheus.yml#L19:

{% for host in (groups['all'] | difference(groups['ceph-grafana'])) %}

and the playbook where the facts are gathered for all group https://github.com/ceph/cephmetrics/blob/e5873d512c98774a758b24375479ae27da57d345/ansible/playbook.yml#L2:L6

- hosts: all
  gather_facts: true
  any_errors_fatal: true
  tags:
  - always

I think the usage of group "all" here can be replaced by using some dynamic inventory. This approach would allow to have the other hosts in the inventory and would made the prometheus.yml template more precise.

@rppietrzak
Copy link
Author

rppietrzak commented Sep 24, 2019

I think it could be solved for example by below code (playbook.yml):

- hosts: localhost
  connection: local
  gather_facts: false
  vars:
    ceph_groups:
      - ceph-grafana
      # These are roles used by ceph-ansible
      - mons
      - agents
      - osds
      - mdss
      - rgws
      - nfss
      - restapis
      - rbdmirrors
      - clients
      - mgrs
      - iscsis
      # This role is (so far) only used for testing
      - cluster
  tasks:
    - name: Creating one group containing all ceph groups - ceph_all
      add_host:
        name: "{{ item }}"
        groups: "ceph_all"
      loop: "{{ lookup('inventory_hostnames', ceph_groups|join(':'), wantlist=True) }}"

- hosts: ceph_all
  gather_facts: true
  any_errors_fatal: true
  tags:
  - always

and the replacing all group in prometheus.yml template by ceph_all:

{% for host in (groups['ceph_all'] | difference(groups['ceph-grafana'])) %}

Group ceph_all can be used as well in other playbooks (not only one used for facts gathering).

Details:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant