---
- name: Stop node service
  service:
    name: "{{ openshift_service_type }}-node"
    state: stopped
  failed_when: false

- name: Stop openvswitch service
  service:
    name: openvswitch
    state: stopped
  when: openshift_node_use_openshift_sdn | bool
  failed_when: false

- name: Ensure containerized services stopped before Docker restart
  service:
    name: "{{ item }}"
    state: stopped
  with_items:
  - etcd_container
  - "{{ openshift_service_type }}-master-api"
  - "{{ openshift_service_type }}-master-controllers"
  - "{{ openshift_service_type }}-node"
  failed_when: false
  when: openshift_is_containerized | bool

- service:
    name: docker
    state: stopped
  register: l_openshift_node_upgrade_docker_stop_result
  until: not (l_openshift_node_upgrade_docker_stop_result is failed)
  retries: 3
  delay: 30
  when:
  - l_docker_upgrade is defined
  - l_docker_upgrade | bool

- name: Stop crio
  service:
    name: cri-o
    state: stopped
  when: openshift_use_crio | bool

# TODO: Need to determine if this is needed long term
# Upgrading cri-o requires that all pods be stopped
- name: Clean up cri-o pods
  script: clean-up-crio-pods.sh
  when: openshift_use_crio | bool

- name: Stop rpm based services
  service:
    name: "{{ item }}"
    state: stopped
  with_items:
  - "{{ openshift_service_type }}-node"
  - openvswitch
  failed_when: false
  when: not openshift_is_containerized | bool
