Subject: [ansible-project] Question:  Network restart stuff

I know that ssh is smart enough to stay connected (or reconnect), but I am
wondering if there is a general rule of thumb to keep in mind when
restarting network services via ansible?  ie.  I am disabling
NetworkManager on all systems, enabling the network, and then restarting
the network.  Any gotchas or anything else to be aware of?

# tasks file for disable_NetworkManager
- name: Check if NetworkManager is installed
  shell: "rpm -qa | grep -i NetworkManager"
  changed_when: false
  no_log: true
  register: nm_installed
  ignore_errors: true

- name: Gather list of ifcfg-* files
  shell: ls "{{ net_path }}" | grep ^ifcfg- | grep 0$ | grep -ve ifcfg-lo -e
\@ # \@ excludes ansible backup files
  register: ifcfg_list
  changed_when: false

- name: Disable NetworkManager control from ifcfg-* files
    path: "{{ net_path }}{{ item }}"
    regexp: "^NM_CONTROLLED.*"
    line: 'NM_CONTROLLED=no'
    state: present
  with_items: "{{ ifcfg_list.stdout_lines }}"

- fail:
    msg: "NetworkManager is not installed on {{ ansible_hostname }}.
 Nothing left to do.  Stopping here to prevent network restart."
  when: nm_installed.rc != 0

- name: Uninstall NetworkManager
    name: "{{ item }}"
    state: absent
  with_items: "{{ nm_installed.stdout_lines  }}"
  when: nm_installed.rc == 0
  notify: Restart Networking

- name: Disable NetworkManager and Enable networking services
    name: "{{}}"
    enabled: "{{item.enabled}}"
    state: "{{item.state}}"
  changed_when: false
    - {name: "NetworkManager", enabled: "no", state: "stopped"}
    - {name: "network", enabled: "yes", state: "started"}
  ignore_errors: true
  notify: Restart Networking
To post to this group, send email to [EMAIL PROTECTED].