---
- hosts: env_{{ env_id }}:&compute
  vars_files:
    - "vars/mos_releases/{{ mos_release }}.yml"
  tasks:

  - name: Restart OpenStack services on computes
    tags: compute_services
    ignore_errors: yes
    service: name={{ item }} state=restarted
    with_items: "{{ compute_services }}"

- hosts: env_{{ env_id }}:&cinder
  vars_files:
    - "vars/mos_releases/{{ mos_release }}.yml"
  tasks:

  - name: Restart Cinder services on Cinder nodes
    tags: cinder_services
    ignore_errors: yes
    service: name={{ item }} state=restarted
    with_items: "{{ cinder_services }}"

- hosts: env_{{ env_id }}:&controller
  vars_files:
    - "vars/mos_releases/{{ mos_release }}.yml"
  tasks:

  - name: Restart OpenStack services on controllers
    tags: controller_services
    ignore_errors: yes
    service: name={{ item }} state=restarted
    with_items: "{{ controller_services }}"

  - name: Restart OpenStack services under Pacemaker
    tags: controller_pcs
    run_once: true
    ignore_errors: yes
    script: files/restart_pcs_resource.sh {{ item }}
    with_items: "{{ controller_pcs_resources }}"

---
- hosts: env_{{ env_id }}:&compute
  vars_files:
    - "vars/mos_releases/{{ mos_release }}.yml"
  tasks:

  - name: Restart OpenStack services on computes
    tags: compute_services
    ignore_errors: yes
    service: name={{ item }} state=restarted
    register: restart_result
    failed_when: restart_result | failed and
                 "no service or tool found for" not in restart_result.msg
    with_items: "{{ compute_services }}"

- hosts: env_{{ env_id }}:&cinder
  vars_files:
    - "vars/mos_releases/{{ mos_release }}.yml"
  tasks:

  - name: Restart Cinder services on Cinder nodes
    tags: cinder_services
    ignore_errors: yes
    service: name={{ item }} state=restarted
    register: restart_result
    failed_when: restart_result | failed and
                 "no service or tool found for" not in restart_result.msg
    with_items: "{{ cinder_services }}"

- hosts: env_{{ env_id }}:&controller
  vars_files:
    - "vars/mos_releases/{{ mos_release }}.yml"
  tasks:

  - name: Restart OpenStack services on controllers
    tags: controller_services
    ignore_errors: yes
    service: name={{ item }} state=restarted
    register: restart_result
    failed_when: restart_result | failed and
                 "no service or tool found for" not in restart_result.msg
    with_items: "{{ controller_services }}"

  - name: Restart OpenStack services under Pacemaker
    tags: controller_pcs
    run_once: true
    ignore_errors: yes
    script: files/restart_pcs_resource.sh {{ item }}
    with_items: "{{ controller_pcs_resources }}"

Fix restart fails for absent services
Fix restart fails for absent services
