]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
cobbler_profile: use the mount module instead of command to mount isos
authorAndrew Schoen <aschoen@redhat.com>
Mon, 18 May 2015 18:09:52 +0000 (13:09 -0500)
committerAndrew Schoen <aschoen@redhat.com>
Wed, 20 May 2015 21:18:21 +0000 (16:18 -0500)
The mount module is idempotent, so we should use that instead.  Also,
clear the mount point each time so that if the playbook fails on the
next run it'll actually remount and complete the rest of the tasks
instead of skipping them because the iso is already mounted.

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
roles/cobbler_profile/tasks/import_distro.yml

index 6ab3cbd02bdbef4bfd16c49290632c29e44fcfc9..7300a4a1ce0b0eaf5c21b8dbfdfc0c980ff79720 100644 (file)
 - 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
-  command: mount -o loop {{ iso_path }} {{ iso_mount }}
+  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.rc == 0
+  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.rc == 0
+  when: mount is defined and mount|changed
 
 - name: Unmount ISO
-  command: umount {{ iso_mount }}
-  when: mount is defined and mount.rc == 0
+  mount:
+    name: "{{ iso_mount }}"
+    src: "{{ iso_path }}"
+    fstype: "iso9660"
+    state: unmounted
+  when: mount is defined and mount|changed
 
 - name: Set kickstart path
   set_fact: