replace command module running mktemp with tempfile module
authorChristian Pointner <equinox@realraum.at>
Sat, 22 Dec 2018 00:02:43 +0000 (01:02 +0100)
committerChristian Pointner <equinox@realraum.at>
Sat, 22 Dec 2018 00:02:43 +0000 (01:02 +0100)
ansible/roles/openwrt/image/tasks/prepare.yml
ansible/roles/usb-install/tasks/main.yml
ansible/roles/vm/install/tasks/main.yml

index b6b67c5..3414371 100644 (file)
@@ -1,11 +1,12 @@
 ---
 - name: Create temporary build directory
-  command: mktemp --tmpdir -d openwrt-{{ inventory_hostname }}.XXXXXX
+  tempfile:
+    state: directory
   register: tmpdir
 
 - set_fact:
-    openwrt_imgbuilder_dir:   "{{ tmpdir.stdout }}"
-    openwrt_imgbuilder_files: "{{ tmpdir.stdout }}/files"
+    openwrt_imgbuilder_dir:   "{{ tmpdir.path }}"
+    openwrt_imgbuilder_files: "{{ tmpdir.path }}/files"
 
 - name: Create the directories for mixins
   file:
index 1523aed..fab32b0 100644 (file)
@@ -1,22 +1,23 @@
 ---
 - block:
     - name: Create temporary workdir
-      command: mktemp -d
+      tempfile:
+        state: directory
       register: tmpdir
 
     - import_role:
         name: preseed
       vars:
-        preseed_tmpdir: "{{ tmpdir.stdout }}"
+        preseed_tmpdir: "{{ tmpdir.path }}"
 
     - name: Copy the preseed initramfs to the artifacts directory
       copy:
-        src: "{{ tmpdir.stdout }}/initrd.preseed.gz"
+        src: "{{ tmpdir.path }}/initrd.preseed.gz"
         dest: "{{ artifacts_dir }}/"
 
 
   always:
     - name: Cleanup temporary workdir
       file:
-        path: "{{ tmpdir.stdout }}"
+        path: "{{ tmpdir.path }}"
         state: absent
index b9201c0..5043fcc 100644 (file)
@@ -33,7 +33,8 @@
 
 - block:
     - name: create a temporary workdir
-      command: mktemp -d
+      tempfile:
+        state: directory
       register: tmpdir
 
     - import_role:
       vars:
         ssh_users_root: "{{ hostvars[hostname].ssh_users_root }}"
         install_interface: enp1s1
-        preseed_tmpdir: "{{ tmpdir.stdout }}"
+        preseed_tmpdir: "{{ tmpdir.path }}"
 
     - name: Make preseed workdir readable by qemu
       acl:
-        path: "{{ tmpdir.stdout }}"
+        path: "{{ tmpdir.path }}"
         state: present
         entity: libvirt-qemu
         etype: user
@@ -58,7 +59,7 @@
         xml: "{{ lookup('template', 'libvirt-domain.xml.j2') }}"
       vars:
         run_installer: yes
-        preseed_tmpdir: "{{ tmpdir.stdout }}"
+        preseed_tmpdir: "{{ tmpdir.path }}"
 
     - name: start vm
       virt:
@@ -90,7 +91,7 @@
   always:
     - name: cleanup temporary workdir
       file:
-        path: "{{ tmpdir.stdout }}"
+        path: "{{ tmpdir.path }}"
         state: absent
 
 - name: define new production vm