---
- name: Check for NetworkManager service
  command: >
    systemctl show NetworkManager
  register: nm_show
  changed_when: false
  ignore_errors: True

- name: Set fact using_network_manager
  set_fact:
    network_manager_active: "{{ True if 'ActiveState=active' in nm_show.stdout else False }}"

- when: not openshift_is_atomic | bool
  block:
  - name: Install dnsmasq
    package:
      name: dnsmasq
      state: installed
    register: result
    until: result is succeeded
  # This works around https://bugzilla.redhat.com/show_bug.cgi?id=1550582
  - name: Restart dbus and systemd-logind if dnsmasq was installed
    systemd:
      name: "{{ item }}"
      state: restarted
    when: result is changed
    with_items:
    - dbus
    - systemd-logind
    register: dbussvcs_restart
  - wait_for_connection:

- name: ensure origin/node directory exists
  file:
    state: directory
    path: "{{ item }}"
    owner: root
    group: root
    mode: '0700'
  with_items:
  - /etc/origin
  - /etc/origin/node

# Relies on ansible in order to configure static config
- import_tasks: dnsmasq/no-network-manager.yml
  when: not network_manager_active | bool

---
- name: Check for NetworkManager service
  command: >
    systemctl show NetworkManager
  register: nm_show
  changed_when: false
  ignore_errors: True

- name: Set fact using_network_manager
  set_fact:
    network_manager_active: "{{ True if 'ActiveState=active' in nm_show.stdout else False }}"

- name: Install dnsmasq
  package:
    name: dnsmasq
    state: installed
  register: result
  until: result is succeeded
  when: not openshift_is_atomic | bool

- name: ensure origin/node directory exists
  file:
    state: directory
    path: "{{ item }}"
    owner: root
    group: root
    mode: '0700'
  with_items:
  - /etc/origin
  - /etc/origin/node

# Relies on ansible in order to configure static config
- import_tasks: dnsmasq/no-network-manager.yml
  when: not network_manager_active | bool

Revert "Don't always update dbus but do restart dbus if dnsmasq changed"
Revert "Don't always update dbus but do restart dbus if dnsmasq changed"
