Feat!: Install ansible tools from PyPI 25/70825/4 v0.12.0
authorAnil Belur <abelur@linuxfoundation.org>
Thu, 6 Oct 2022 13:04:11 +0000 (23:04 +1000)
committerAnil Belur <abelur@linuxfoundation.org>
Fri, 7 Oct 2022 01:50:59 +0000 (11:50 +1000)
Install ansible through system packages causes dependencies
conflicts on CentOS 8 platform therefore update packer
templates to use ansible provisioner created
through venv.

Error:
Problem: package ansible-5.4.0-3.el8.noarch requires
(ansible-core >= 2.12.2 with ansible-core < 2.13), but none
of the providers can be installed

Issue-ID: RELENG-4473
Change-Id: I1d562386b4408c9674271e813dcd2aea6632e709
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
ansible-galaxy.sh
ansible-playbook.sh [new file with mode: 0755]
docs/requirements.rst
docs/update-images.rst
releasenotes/notes/get-ansible-from-pypi-702606c724a84d26.yaml [new file with mode: 0644]
templates/builder-aws.json
templates/builder.json
templates/docker-aws.json
templates/docker.json

index 1d9a080..07b0049 100755 (executable)
@@ -13,6 +13,15 @@ set -eu -o pipefail -o noglob
 
 echo "----> ansible-galaxy.sh"
 
+wget -q https://raw.githubusercontent.com/lfit/releng-global-jjb/master/jenkins-init-scripts/lf-env.sh \
+    -O ~/lf-env.sh
+
+# shellcheck disable=SC1090
+. ~/lf-env.sh
+
+lf-activate-venv --python python3 --venv-file "/tmp/.ansible_venv" \
+    ansible~=2.9.27
+
 ansible_roles_path=${1:-.galaxy}
 ansible_requirements_file=${2:-requirements.yaml}
 script_dir=$(dirname "$0")
diff --git a/ansible-playbook.sh b/ansible-playbook.sh
new file mode 100755 (executable)
index 0000000..490b63a
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2022 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+if command -v "$(cat /tmp/.ansible_venv)/bin/ansible-playbook" &> /dev/null; then
+    source "$(cat /tmp/.ansible_venv)/bin/activate" && ANSIBLE_FORCE_COLOR=1 \
+        PYTHONUNBUFFERED=1 "$(cat /tmp/.ansible_venv)/bin/ansible-playbook" "$@"
+elif command -v "$(which ansible-playbook)"; then
+    "$(which ansible-playbook)" "$@"
+else
+    echo "ERROR: ansible-playbook not found"
+    exit
+fi
index 18d62f9..e0f42de 100644 (file)
@@ -2,14 +2,13 @@
 Requirements
 ############
 
-* Ansible 2.4.1 or later
-* Packer 1.3.2 or later
+* Ansible 2.9.27 or later
+* Packer 1.8.2 or later
 
-Install Ansible via pip in a virtualenv if the version is not available via
-your local package manager.
+Install Ansible via pip in a virtualenv to build images.
 
 .. code-block:: bash
 
-   virtualenv ansible
-   source ansible/bin/activate
-   pip install ansible~=2.4.1
+    virtualenv -p $(which python3) ~/venv/.ansible
+    source ~/venv/.ansible/bin/activate
+    pip3 install ansible~=2.9.27
index 6cf9a2d..7b30d17 100644 (file)
@@ -10,8 +10,8 @@ OpenStack cloud.
 
    .. code-block:: bash
 
-      pip install lftools[openstack]
-      yum/apt install qemu-img
+       pip install lftools[openstack]
+       yum/apt install qemu-img
 
 
 2. Fetch the image file in .img format
diff --git a/releasenotes/notes/get-ansible-from-pypi-702606c724a84d26.yaml b/releasenotes/notes/get-ansible-from-pypi-702606c724a84d26.yaml
new file mode 100644 (file)
index 0000000..de499f5
--- /dev/null
@@ -0,0 +1,14 @@
+---
+prelude: >
+    Install ansible and ansible-playbook using PyPI.
+issues:
+  - |
+    Error:
+      Problem: package ansible-5.4.0-3.el8.noarch requires
+      (ansible-core >= 2.12.2 with ansible-core < 2.13), but none
+      of the providers can be installed
+fixes:
+  - |
+    Install ansible through system packages causes dependencies
+    conflicts on CentOS 8 platform therefore update packer
+    templates to use ansible provisioner created through venv.
index f5a0f01..b7d7c60 100644 (file)
@@ -58,6 +58,7 @@
     {
       "type": "ansible",
       "user": "{{user `ssh_user`}}",
+      "command": "./common-packer/ansible-playbook.sh",
       "playbook_file": "provision/local-builder.yaml",
       "ansible_env_vars": [
         "ANSIBLE_NOCOWS=1",
index 0fa217d..1bc82f5 100644 (file)
@@ -55,6 +55,7 @@
     },
     {
       "type": "ansible",
+      "command": "./common-packer/ansible-playbook.sh",
       "playbook_file": "provision/local-builder.yaml",
       "ansible_env_vars": [
         "ANSIBLE_NOCOWS=1",
index 831605d..26673ac 100644 (file)
@@ -58,6 +58,7 @@
     {
       "type": "ansible",
       "user": "{{user `ssh_user`}}",
+      "command": "./common-packer/ansible-playbook.sh",
       "playbook_file": "provision/local-docker.yaml",
       "ansible_env_vars": [
         "ANSIBLE_NOCOWS=1",
index c4699b0..1b57d57 100644 (file)
@@ -55,6 +55,7 @@
     },
     {
       "type": "ansible",
+      "command": "./common-packer/ansible-playbook.sh",
       "playbook_file": "provision/local-docker.yaml",
       "ansible_env_vars": [
         "ANSIBLE_NOCOWS=1",