Feat!: Add builder macro to set ansible.cfg file 95/69095/3
authorAnil Belur <abelur@linuxfoundation.org>
Tue, 9 Nov 2021 00:25:03 +0000 (10:25 +1000)
committerAnil Belur <abelur@linuxfoundation.org>
Tue, 9 Nov 2021 22:24:48 +0000 (08:24 +1000)
Add packer builder macros to create a 'ansible.cfg' file.
This is required by packer build jobs to set ansible host
configuration. The job or image specific configuration can
be created using JCasC custom files in the ci-man repository.

Issue-ID: RELENG-4032
Change-Id: Ia9fc4d26341228ba8009de6d2ec3c46e31bfc45b
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
docs/jjb/lf-ci-jobs.rst
docs/jjb/lf-macros.rst
jjb/lf-macros.yaml
releasenotes/notes/add-ansible-config-file-provider-7bcd466a47ba02b8.yaml [new file with mode: 0644]

index 439b2e7..315bfc3 100644 (file)
@@ -746,6 +746,10 @@ Packer Merge
 
 Packer Merge job runs `packer build` to build system images in the cloud.
 
 
 Packer Merge job runs `packer build` to build system images in the cloud.
 
+This job requires a Config File Provider file named ``ansible-cfg`` created
+on Jenkins. The file can include ansible host configuration required for the
+environment.
+
 :Template Names:
     - {project-name}-packer-merge-{platforms}-{templates}
     - gerrit-packer-merge
 :Template Names:
     - {project-name}-packer-merge-{platforms}-{templates}
     - gerrit-packer-merge
@@ -815,6 +819,10 @@ Packer Verify job runs ``packer validate`` to verify packer configuration. The
 verify job checks superficial syntax of the template and other files. It does
 not attempt to build an image, and cannot detect all possible build issues.
 
 verify job checks superficial syntax of the template and other files. It does
 not attempt to build an image, and cannot detect all possible build issues.
 
+This job requires a Config File Provider file named ``ansible-cfg`` created
+on Jenkins. The file can include ansible host configuration required for the
+environment.
+
 :Template Names:
     - {project-name}-packer-verify
     - gerrit-packer-verify
 :Template Names:
     - {project-name}-packer-verify
     - gerrit-packer-verify
index 1ea2cfa..66a25a8 100644 (file)
@@ -12,6 +12,11 @@ This macro will post a comment to the gerrit patchset if the build
 creates a file named gerrit_comment.txt
 To use this macro add it to the list of builders.
 
 creates a file named gerrit_comment.txt
 To use this macro add it to the list of builders.
 
+lf-ansible-config-file-provider
+-------------------------------
+
+Provisions files required by the ansible, namely
+"~/.ansible/ansible.cfg" in the Jenkins home directory.
 
 lf-fetch-dependent-patches
 --------------------------
 
 lf-fetch-dependent-patches
 --------------------------
index ab46c35..57edc3a 100644 (file)
     builders:
       - shell: !include-raw: ../shell/comment-to-gerrit.sh
 
     builders:
       - shell: !include-raw: ../shell/comment-to-gerrit.sh
 
+- builder:
+    name: lf-ansible-config-file-provider
+    builders:
+      - config-file-provider:
+          files:
+            - file-id: "ansible-cfg"
+              target: "$HOME/.ansible/ansible.cfg"
+
 - builder:
     name: lf-fetch-dependent-patches
     builders:
 - builder:
     name: lf-fetch-dependent-patches
     builders:
 - builder:
     name: lf-infra-packer-build
     builders:
 - builder:
     name: lf-infra-packer-build
     builders:
+      - lf-ansible-config-file-provider
       - conditional-step:
           condition-kind: boolean-expression
           condition-expression: "{openstack}"
       - conditional-step:
           condition-kind: boolean-expression
           condition-expression: "{openstack}"
diff --git a/releasenotes/notes/add-ansible-config-file-provider-7bcd466a47ba02b8.yaml b/releasenotes/notes/add-ansible-config-file-provider-7bcd466a47ba02b8.yaml
new file mode 100644 (file)
index 0000000..08d528f
--- /dev/null
@@ -0,0 +1,15 @@
+---
+upgrade:
+  - |
+    This change requires creation of a custom managed file (ansible.cfg)
+    on the Jenkins environment with the default line
+    "remote_src = ~/.ansible/tmp".
+features:
+  - |
+    Add packer builder macros to create a 'ansible.cfg' file.
+    This is required by packer build jobs to set ansible host
+    configuration. The job or image specific configuration can be created
+    using JCasC custom files in the ci-man repository.
+
+    Example configuration:
+    https://github.com/ansible/ansible/blob/stable-2.11/examples/ansible.cfg