]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
Populate systems
authorZack Cerza <zack@redhat.com>
Fri, 5 Jun 2015 17:46:33 +0000 (11:46 -0600)
committerZack Cerza <zack@redhat.com>
Mon, 29 Jun 2015 22:37:06 +0000 (16:37 -0600)
Disable netboot by default, so we don't accidentally reimage systems
unintentionally

Signed-off-by: Zack Cerza <zack@redhat.com>
roles/cobbler/tasks/main.yml
roles/cobbler/tasks/populate_systems.yml [new file with mode: 0644]

index bb35e13221eee06a5f189cd149f6ef8f1a89ebd2..9687145226f163bc53350bfda17697c5217026d5 100644 (file)
@@ -51,3 +51,7 @@
   service:
     name: "{{ httpd_service }}"
     state: started
+
+- include: populate_systems.yml
+  tags:
+    - systems
diff --git a/roles/cobbler/tasks/populate_systems.yml b/roles/cobbler/tasks/populate_systems.yml
new file mode 100644 (file)
index 0000000..59ddc89
--- /dev/null
@@ -0,0 +1,27 @@
+---
+- name: Get list of cobbler systems
+  command: cobbler system list
+  register: cmd_cobbler_systems
+  no_log: true
+
+- name: Set cobbler_systems_current
+  set_fact:
+    cobbler_systems_current: "[{% for host in cmd_cobbler_systems.stdout.strip().split() %}'{{ host }}.{{ lab_domain }}, {% endfor %}]"
+
+- name: set cobbler_systems_add
+  set_fact:
+    cobbler_systems_add:
+      "{{ groups.cobbler_managed | difference(cobbler_systems_current) }}"
+
+- name: Add missing systems to cobbler
+  command: cobbler system add --name={{ item.split('.')[0] }} --profile={{ default_profile }} --mac={{ hostvars[item].mac }} --ip-address={{ hostvars[item].ip }} --interface={{ hostvars[item].interface }} --kopts="{{ hostvars[item].kernel_options }}" --netboot-enabled false
+  with_items: cobbler_systems_add
+
+- name: set cobbler_systems_update
+  set_fact:
+    cobbler_systems_update:
+      "{{ groups.cobbler_managed | intersect(cobbler_systems_current) }}"
+
+- name: Update existing systems in cobbler
+  command: cobbler system edit --name={{ item.split('.')[0] }} --mac={{ hostvars[item].mac }} --ip-address={{ hostvars[item].ip }} --interface={{ hostvars[item].interface }} --kopts="{{ hostvars[item].kernel_options }}"
+  with_items: cobbler_systems_update