]> git.apps.os.sepia.ceph.com Git - ceph-build.git/commitdiff
builder.yml: make playbook more flexible for finding templates
authorDan Mick <dan.mick@redhat.com>
Wed, 1 Oct 2025 02:23:34 +0000 (19:23 -0700)
committerDan Mick <dan.mick@redhat.com>
Tue, 7 Oct 2025 22:33:56 +0000 (15:33 -0700)
Many things are relative to 'playbook_dir', but some people
keep a symlink to examples/builder.yml and some don't.  I can't
think of a way to fix, say, the module library path 'library/',
but I can make it better for templates.

Signed-off-by: Dan Mick <dan.mick@redhat.com>
ansible/examples/builder.yml

index d422ffa1dcc29c495c333b6428612a25200c7f8e..ecec0b4ad4b89a8abae5cd3ddae7feaff14b69fd 100644 (file)
             force: yes
           register: jar_changed
 
+        - name: look for templates/
+          ansible.builtin.stat:
+            path: templates
+          delegate_to: localhost
+          run_once: true
+          register: template_dir
+
+        - name: choose proper templates dir
+          set_fact:
+            template_path: "{{ 'templates' if template_dir.stat.exists else '../templates' }}"
+
+        - name: echo template_path
+          debug:
+            msg: "template_path: {{ template_path }}"
+
         - name: Install the systemd unit files for jenkins
           ansible.builtin.template:
-            src: "{{ playbook_dir }}/../templates/systemd/jenkins.{{ item }}.j2"
+            src: "{{ template_path }}/systemd/jenkins.{{ item }}.j2"
             dest: "/etc/systemd/system/jenkins.{{ item }}"
             force: yes
           with_items: