]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
Undo resolvconf hackery
authorZack Cerza <zack@redhat.com>
Thu, 3 Dec 2015 19:12:00 +0000 (12:12 -0700)
committerZack Cerza <zack@redhat.com>
Fri, 4 Dec 2015 00:04:38 +0000 (17:04 -0700)
Signed-off-by: Zack Cerza <zack@redhat.com>
roles/testnode/tasks/main.yml
roles/testnode/tasks/resolvconf.yml [new file with mode: 0644]

index bc1c8772662ee6b8299c58732ac9fa0341555032..3a751a55a94f0fe11c5099512145732d82f1edbd 100644 (file)
   tags:
     - pip
 
+# include resolv.conf setup
+- include: resolvconf.yml
+  tags:
+    - resolvconf
+
 # Touch a file to indicate we are done. This is something chef did;
 # teuthology.task.internal.vm_setup() expects it.
 - name: Touch /ceph-qa-ready
diff --git a/roles/testnode/tasks/resolvconf.yml b/roles/testnode/tasks/resolvconf.yml
new file mode 100644 (file)
index 0000000..21af204
--- /dev/null
@@ -0,0 +1,40 @@
+---
+- name: Purge resolvconf
+  apt:
+    name: resolvconf
+    state: absent
+    purge: yes
+  when: ansible_pkg_mgr == "apt"
+
+- name: Set interface
+  set_fact:
+    interface: "{{ hostvars[inventory_hostname].interface|default('eth0') }}"
+
+- name: Check for presence of /etc/network/interfaces
+  stat:
+    path: /etc/network/interfaces
+    get_checksum: no
+    get_md5: no
+  register: etc_network_interfaces
+
+- name: Rewrite /etc/network/interfaces to use dhcp
+  replace:
+    dest: /etc/network/interfaces
+    # This regexp matches a stanza like:
+    # iface eth0 inet static
+    #     address 10.8.128.17
+    #     netmask 255.255.248.0
+    #     gateway 10.8.135.254
+    #     broadcast 10.8.135.255
+    regexp: '^iface {{ interface }} inet static(\n\ +.*)+'
+    replace: "iface {{ interface }} inet dhcp\n"
+  when: etc_network_interfaces.stat.exists
+  register: dhcp_enabled
+
+- name: Set bounce_interface if we just enabled dhcp
+  set_fact:
+    bounce_interface: "{{ dhcp_enabled|changed }}"
+
+- name: ifdown and ifup
+  shell: "ifdown {{ interface }} && ifup {{ interface }}"
+  when: bounce_interface == "True"