]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
cobbler_profile: Split out ISO importing
authorZack Cerza <zack@redhat.com>
Tue, 15 Sep 2015 21:21:45 +0000 (15:21 -0600)
committerZack Cerza <zack@redhat.com>
Wed, 16 Sep 2015 23:02:39 +0000 (17:02 -0600)
So that we can have a separate codepath for importing distros from
non-ISO sources.

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

index 6140ab46347ee207b3c712c4ac20f0dbd5641922..16742bd90452eed802f06e9e8059b89c4ab8ba8f 100644 (file)
   command: cobbler profile find --name {{ distro_name }}
   # Skip if the iso field is empty; this allows us to mention distros with 
   # ISOs that are internal, but leave the URL out.
-  when: distro.iso != ''
+  when: distro.iso != '' or distro.kernel != ''
   register: profile
   ignore_errors: true
   changed_when: false
 
-- name: Set ISO name
-  set_fact:
-      iso_name: "{{ distro.iso.split('/')[-1] }}"
-
-- name: Set ISO path
-  set_fact:
-      iso_path: "{{ iso_dir }}/{{ iso_name }}"
-
-- include: download_iso.yml
+- include: import_distro_iso.yml
   when: distro.iso != ''
 
-# we do this so that if the playbook fails
-# after mounting and we need to run it again
-# then we'll remount and complete the rest
-# of the tasks like it's the first run
-- name: Clear the mount point.
-  mount:
-    name: "{{ iso_mount }}"
-    src: "{{ iso_path }}"
-    fstype: "iso9660"
-    state: unmounted
-
-- name: Mount ISO
-  mount:
-    name: "{{ iso_mount }}"
-    src: "{{ iso_path }}"
-    opts: "loop"
-    fstype: "iso9660"
-    state: mounted
-  when: download|changed or (iso_stat.stat.exists and
-        profile is defined and profile.stdout == '')
-  register: mount
-
-- name: Set arch
-  set_fact:
-      arch: "{{ distro.arch|default('x86_64') }}"
-  when: mount is defined and mount|changed
-
-- name: Import the distro (also creates the profile)
-  command: cobbler import --path={{ iso_mount }} --name={{ distro_name }} --arch={{ arch }}
-  register: import
-  when: mount is defined and mount|changed
-
-- name: Unmount ISO
-  mount:
-    name: "{{ iso_mount }}"
-    src: "{{ iso_path }}"
-    fstype: "iso9660"
-    state: unmounted
-  when: mount is defined and mount|changed
+# make sure to define profile_found?
 
 # If either the profile already existed or we successfully imported the
 # distro, we might want to update other options in the profile. i.e. kickstarts
diff --git a/roles/cobbler_profile/tasks/import_distro_iso.yml b/roles/cobbler_profile/tasks/import_distro_iso.yml
new file mode 100644 (file)
index 0000000..7340bbf
--- /dev/null
@@ -0,0 +1,51 @@
+---
+- name: Set ISO name
+  set_fact:
+      iso_name: "{{ distro.iso.split('/')[-1] }}"
+
+- name: Set ISO path
+  set_fact:
+      iso_path: "{{ iso_dir }}/{{ iso_name }}"
+
+- include: download_iso.yml
+  when: distro.iso != ''
+
+# we do this so that if the playbook fails
+# after mounting and we need to run it again
+# then we'll remount and complete the rest
+# of the tasks like it's the first run
+- name: Clear the mount point.
+  mount:
+    name: "{{ iso_mount }}"
+    src: "{{ iso_path }}"
+    fstype: "iso9660"
+    state: unmounted
+
+- name: Mount ISO
+  mount:
+    name: "{{ iso_mount }}"
+    src: "{{ iso_path }}"
+    opts: "loop"
+    fstype: "iso9660"
+    state: mounted
+  when: download|changed or (iso_stat.stat.exists and
+        profile is defined and profile.stdout == '')
+  register: mount
+
+- name: Set arch
+  set_fact:
+      arch: "{{ distro.arch|default('x86_64') }}"
+  when: mount is defined and mount|changed
+
+- name: Import the distro (also creates the profile)
+  command: cobbler import --path={{ iso_mount }} --name={{ distro_name }} --arch={{ arch }}
+  register: import
+  when: mount is defined and mount|changed
+
+- name: Unmount ISO
+  mount:
+    name: "{{ iso_mount }}"
+    src: "{{ iso_path }}"
+    fstype: "iso9660"
+    state: unmounted
+  when: mount is defined and mount|changed