]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
lv-create: use the template module to write log file
authorAndrew Schoen <aschoen@redhat.com>
Wed, 8 Aug 2018 21:43:55 +0000 (16:43 -0500)
committerSébastien Han <seb@redhat.com>
Thu, 16 Aug 2018 14:38:23 +0000 (16:38 +0200)
The copy module will not expand the template and render the variables
included, so we must use template.

Creating a temp file and using it locally means that you must run the
playbook with sudo privledges, which I don't think we want to require.
This introduces a logfile_path variable that the user can use to control
where the logfile is written to, defaulting to the cwd.

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
infrastructure-playbooks/lv-create.yml
infrastructure-playbooks/templates/lv-create-log.j2 [new file with mode: 0644]

index 9d4ee8077007fed4ddd06c0b02d04a3443fa67cc..1217499fe213f52b2dc25e5fd2e596f9451348b2 100644 (file)
@@ -2,23 +2,6 @@
   hosts:
   - osds
 
-  vars:
-    logfile: |
-      Suggested cut and paste under "lvm_volumes:" in "group_vars/osds.yml" for configuring with osd_scenario=lvm
-      -----------------------------------------------------------------------------------------------------------
-      {% for lv in nvme_device_lvs %}
-        - data: {{ lv.lv_name }}
-          data_vg: {{ nvme_vg_name }}
-          journal: {{ lv.journal_name }}
-          journal_vg: {{ nvme_vg_name }}
-      {% endfor %}
-      {% for hdd in hdd_devices %}
-        - data: {{ hdd_lv_prefix }}-{{ hdd.split('/')[-1] }}
-          data_vg: {{ hdd_vg_prefix }}-{{ hdd.split('/')[-1] }}
-          journal: {{ hdd_journal_prefix }}-{{ hdd.split('/')[-1] }}
-          journal_vg: {{ nvme_vg_name }}
-      {% endfor %}
-
   tasks:
 
   - name: include vars of lv_vars.yaml
     with_items:
       - "{{ hdd_devices }}"
 
-  # Write ending configuration logfile
-  - name: create temporary logfile
-    tempfile:
-      state: file
-      suffix: logfile
-    register: temp_file
-
-  - name: print logfile details
-    debug: var=temp_file
-
-  - name: write output for osds.yml to logfile /tmp/ansible.*logfile
-    copy:
-      content: "{{ logfile }}"
-      dest: "{{ temp_file.path }}"
+  - name: "write output for osds.yml to {{ logfile_path }}"
+    become: false
+    template:
+      src: "templates/lv-create-log.j2"
+      dest: "{{ logfile_path }}"
     delegate_to: localhost
diff --git a/infrastructure-playbooks/templates/lv-create-log.j2 b/infrastructure-playbooks/templates/lv-create-log.j2
new file mode 100644 (file)
index 0000000..8b0d78f
--- /dev/null
@@ -0,0 +1,14 @@
+Suggested cut and paste under "lvm_volumes:" in "group_vars/osds.yml" for configuring with osd_scenario=lvm
+-----------------------------------------------------------------------------------------------------------
+{% for lv in nvme_device_lvs %}
+- data: {{ lv.lv_name }}
+  data_vg: {{ nvme_vg_name }}
+  journal: {{ lv.journal_name }}
+  journal_vg: {{ nvme_vg_name }}
+{% endfor %}
+{% for hdd in hdd_devices %}
+- data: {{ hdd_lv_prefix }}-{{ hdd.split('/')[-1] }}
+  data_vg: {{ hdd_vg_prefix }}-{{ hdd.split('/')[-1] }}
+  journal: {{ hdd_journal_prefix }}-{{ hdd.split('/')[-1] }}
+  journal_vg: {{ nvme_vg_name }}
+{% endfor %}