From: Anil Belur Date: Tue, 14 May 2019 01:37:39 +0000 (+1000) Subject: Migrate devstack images to Ansible provisioners X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=releng%2Fbuilder.git;a=commitdiff_plain;h=7cb8393d6e8f6e9956eeab8d98611625f696cd36 Migrate devstack images to Ansible provisioners Migrate the packer provisioners to use Ansible playbooks. Remove the shell scripts used to provision custom devstack {pre-pip-{queens,rocky}} images. Change-Id: I42a114db01208b96a0fd9116a4404bdd61688376 Signed-off-by: Anil Belur --- diff --git a/packer/provision/devstack-pre-pip.sh b/packer/provision/devstack-pre-pip.sh deleted file mode 100644 index 8a910d972..000000000 --- a/packer/provision/devstack-pre-pip.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash - -# force any errors to cause the script and job to end in failure -set -xeu -o pipefail - -# Install xpath -yum install -y perl-XML-XPath python-pip - -# install crudini command line tool for editing config files -yum install -y crudini - -echo '---> Installing non-baseline requirements' -yum install -y deltarpm nc python{,-{crypto,devel,lxml,setuptools}} \ - @development {lib{xml2,xslt,ffi},openssl}-devel git wget - -echo '---> Updating net link setup' -if [ ! -f /etc/udev/rules.d/80-net-setup-link.rules ]; then - ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules -fi - -echo '---> Pre-installing yum and pip packages' -projs="requirements keystone glance cinder neutron nova horizon" -# shellcheck disable=SC2154 -branch=${os_branch} -# strip the "stable" off of the branch -branch_name=$(cut -d'/' -f2 <<< "${branch}") - -# Do not upgrade pip to v10. v10 does not allow uninstalling -# distutils installed packages. This fails the openstack pip installs -# below when it attempts to uninstall packages. -# devstack patch that is trying to get pip 10 working: -# https://review.openstack.org/#/c/561597/ -# wget https://bootstrap.pypa.io/get-pip.py -# python get-pip.py - -mkdir tmp -cd tmp - -git clone https://github.com/openstack-dev/devstack.git -(cd devstack && git checkout "${branch}") -sed -e 's/#.*//' devstack/files/rpms/general | xargs yum install -y - -base_url=https://github.com/openstack/ -for proj in $projs -do - git clone "${base_url}${proj}" - (cd "${proj}" && git checkout "${branch}") - pip install -c requirements/upper-constraints.txt -e "${proj}" - pip install -c requirements/upper-constraints.txt -r "${proj}/test-requirements.txt" -done - -echo '---> Installing openvswitch from relevant openstack branch' -yum install -y "centos-release-openstack-${branch_name}" - -# install 2.8.2 for queens. -# 2.9.0 is the current version in openstack-queens, but it is buggy. -# Remove this when https://review.rdoproject.org/r/#/c/13839/ merges and 2.9.2 is in the repo. -yum repolist -yum --showduplicates list openvswitch -if [ "${branch}" == "stable/queens" ]; then - yum install -y --nogpgcheck openvswitch-2.8.2-1.el7 -else - yum install -y --nogpgcheck openvswitch -fi -cd "$OLDPWD" -rm -fr tmp - -# vim: sw=4 ts=4 sts=4 et : diff --git a/packer/provision/devstack-pre-pip.yaml b/packer/provision/devstack-pre-pip.yaml new file mode 100644 index 000000000..b70b2bdfe --- /dev/null +++ b/packer/provision/devstack-pre-pip.yaml @@ -0,0 +1,135 @@ +--- +- import_playbook: ../common-packer/provision/baseline.yaml + +- hosts: all + become_user: root + become_method: sudo + + pre_tasks: + - include_role: name=lfit.system-update + + tasks: + - name: 'Install devstack dependencies' + block: + - name: Install xpath dependencies + yum: + name: + - perl-XML-XPath + - python-pip + - crudini + state: present + become: true + - name: Install non-baseline requirements + yum: + name: + - deltarpm + - python + - python-crypto + - python-devel + - python-lxml + - python-setuptools + - libxml2-devel + - libxslt-devel + - libffi-devel + - openssl-devel + - "@development" + state: present + become: true + - name: check if net link setup exists + stat: + path: /etc/udev/rules.d/80-net-setup-link.rules + register: rules_file_exists + - name: Update net link setup + file: + src: /dev/null + dest: /etc/udev/rules.d/80-net-setup-link.rules + state: link + force: yes + become: true + when: rules_file_exists.stat.exists == true + - name: 'Pre-Install yum and pip packages' + block: + - name: Create /tmp/devstack directory + file: + path: /tmp/devstack + state: directory + mode: 0755 + - name: Fetch openstack devstack-dev repo + git: + repo: https://github.com/openstack-dev/devstack.git + dest: /tmp/devstack + version: '{{ os_branch }}' + - name: "Read openstack devstack dependencies" + shell: "sed -e 's/#.*//' /tmp/devstack/files/rpms/general" + register: sed_output + args: + warn: False + - name: "Install non-baseline requirements for {{ os_branch }}" + yum: 'name={{item}} state=present' + with_items: + - "{{ sed_output.stdout_lines }}" + become: true + - name: git clone openstack core projects + git: repo='https://github.com/openstack/{{ item }}.git' + dest='/tmp/devstack/{{ item }}' + version='{{ os_branch }}' + with_items: + - requirements + - keystone + - glance + - cinder + - neutron + - nova + - horizon + - name: Install pip dependencies + shell: | + cd "{{ item }}" + git branch -a + cd .. + pwd + pip install -c requirements/upper-constraints.txt -e "{{ item }}" + pip install -c requirements/upper-constraints.txt -r "{{ item }}/test-requirements.txt" + # ignore non-zero return code + exit 0 + args: + chdir: /tmp/devstack + warn: False + with_items: + - requirements + - keystone + - glance + - cinder + - neutron + - nova + - horizon + become: true + + - name: 'Install openvswitch from relevant openstack branch' + block: + - name: 'Install CentOS openstack release {{ rdo_branch }}' + yum: + name: 'centos-release-openstack-{{ rdo_branch }}' + state: present + become: true + - name: 'Install openvswitch 2.8.2 for stable/queens' + yum: + name: openvswitch-2.8.2-1.el7 + state: present + disable_gpg_check: yes + when: rdo_branch == 'queens' + become: true + - name: 'Install openvswitch latest for stable/rocky' + yum: + name: openvswitch + state: present + disable_gpg_check: yes + when: rdo_branch == 'rocky' + become: true + + - name: 'Cleanup devstack directory' + block: + - name: "Removing /tmp/devstack" + file: + path: /tmp/devstack + state: absent + become: true diff --git a/packer/provision/devstack.sh b/packer/provision/devstack.sh deleted file mode 100644 index a420da9dc..000000000 --- a/packer/provision/devstack.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# force any errors to cause the script and job to end in failure -set -xeu -o pipefail - -# Install xpath -yum install -y perl-XML-XPath python-pip - -# install crudini command line tool for editing config files -yum install -y crudini - -echo '---> Installing non-baseline requirements' -yum install -y deltarpm python{,-{crypto,devel,lxml,setuptools}} \ - @development {lib{xml2,xslt,ffi},openssl}-devel - -echo '---> Updating net link setup' -if [ ! -f /etc/udev/rules.d/80-net-setup-link.rules ]; then - ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules -fi - -echo "***************************************************" -echo "* PLEASE RELOAD THIS VAGRANT BOX BEFORE USE *" -echo "***************************************************" - -# vim: sw=4 ts=4 sts=4 et : diff --git a/packer/provision/devstack.yaml b/packer/provision/devstack.yaml new file mode 100644 index 000000000..46e41c68e --- /dev/null +++ b/packer/provision/devstack.yaml @@ -0,0 +1,49 @@ +--- +- import_playbook: ../common-packer/provision/baseline.yaml + +- hosts: all + become_user: root + become_method: sudo + + pre_tasks: + - include_role: name=lfit.system-update + + tasks: + - name: 'Install devstack dependencies' + block: + - name: Install xpath dependencies + yum: + name: + - perl-XML-XPath + - python-pip + - crudini + state: present + become: true + - name: Installing non-baseline requirements + yum: + name: + - deltarpm + - python + - python-crypto + - python-devel + - python-lxml + - python-setuptools + - libxml2-devel + - libxslt-devel + - libffi-devel + - openssl-devel + - "@development" + state: present + become: true + - name: check if net link setup exists + stat: + path: /etc/udev/rules.d/80-net-setup-link.rules + register: rules_file_exists + - name: Update net link setup + file: + src: /dev/null + dest: /etc/udev/rules.d/80-net-setup-link.rules + state: link + force: yes + become: true + when: rules_file_exists.stat.exists == true diff --git a/packer/templates/devstack-pre-pip-queens.json b/packer/templates/devstack-pre-pip-queens.json index 576f7f137..367ef8b40 100644 --- a/packer/templates/devstack-pre-pip-queens.json +++ b/packer/templates/devstack-pre-pip-queens.json @@ -1,5 +1,6 @@ { "variables": { + "ansible_roles_path": ".galaxy", "base_image": null, "distro": null, "cloud_network": null, @@ -9,19 +10,20 @@ }, "builders": [ { - "type": "openstack", - "region": "ca-ymq-1", - "availability_zone": "ca-ymq-2", - "ssh_username": "{{user `ssh_user`}}", - "ssh_proxy_host": "{{user `ssh_proxy_host`}}", + "name": "vexxhost", "image_name": "ZZCI - {{user `distro`}} - devstack-queens - {{isotime \"20060102-150405.000\"}}", "instance_name": "{{user `distro`}}-devstack-queens-{{uuid}}", "source_image_name": "{{user `base_image`}}", - "flavor": "v1-standard-1", + "type": "openstack", + "region": "ca-ymq-1", + "availability_zone": "ca-ymq-2", "networks": [ "{{user `cloud_network`}}" ], "user_data_file": "{{user `cloud_user_data`}}", + "ssh_username": "{{user `ssh_user`}}", + "ssh_proxy_host": "{{user `ssh_proxy_host`}}", + "flavor": "v1-standard-1", "metadata": { "ci_managed": "yes" } @@ -30,17 +32,30 @@ "provisioners": [ { "type": "shell", - "environment_vars": [ - "os_branch=stable/queens", - "rdo_branch=queens" - ], "scripts": [ - "provision/baseline.sh", - "provision/devstack-pre-pip.sh", - "provision/system_reseal_local_env.sh", - "provision/system_reseal.sh" + "common-packer/provision/install-python.sh" ], "execute_command": "chmod +x {{ .Path }}; if [ \"$UID\" == \"0\" ]; then {{ .Vars }} '{{ .Path }}'; else {{ .Vars }} sudo -E '{{ .Path }}'; fi" + }, + { + "type": "shell-local", + "command": "./common-packer/ansible-galaxy.sh {{user `ansible_roles_path`}}" + }, + { + "type": "ansible", + "playbook_file": "provision/devstack-pre-pip.yaml", + "ansible_env_vars": [ + "ANSIBLE_DEBUG=False", + "ANSIBLE_NOCOWS=1", + "ANSIBLE_PIPELINING=True", + "ANSIBLE_ROLES_PATH={{user `ansible_roles_path`}}", + "ANSIBLE_CALLBACK_WHITELIST=profile_tasks", + "ANSIBLE_STDOUT_CALLBACK=debug" + ], + "extra_arguments": [ + "--extra-vars", + "os_branch=stable/queens rdo_branch=queens" + ] } ] } diff --git a/packer/templates/devstack-pre-pip-rocky.json b/packer/templates/devstack-pre-pip-rocky.json index e892bc314..7798f97be 100644 --- a/packer/templates/devstack-pre-pip-rocky.json +++ b/packer/templates/devstack-pre-pip-rocky.json @@ -1,5 +1,6 @@ { "variables": { + "ansible_roles_path": ".galaxy", "base_image": null, "distro": null, "cloud_network": null, @@ -9,19 +10,20 @@ }, "builders": [ { - "type": "openstack", - "region": "ca-ymq-1", - "availability_zone": "ca-ymq-2", - "ssh_username": "{{user `ssh_user`}}", - "ssh_proxy_host": "{{user `ssh_proxy_host`}}", + "name": "vexxhost", "image_name": "ZZCI - {{user `distro`}} - devstack-rocky - {{isotime \"20060102-150405.000\"}}", "instance_name": "{{user `distro`}}-devstack-rocky-{{uuid}}", "source_image_name": "{{user `base_image`}}", - "flavor": "v1-standard-1", + "type": "openstack", + "region": "ca-ymq-1", + "availability_zone": "ca-ymq-2", "networks": [ "{{user `cloud_network`}}" ], "user_data_file": "{{user `cloud_user_data`}}", + "ssh_username": "{{user `ssh_user`}}", + "ssh_proxy_host": "{{user `ssh_proxy_host`}}", + "flavor": "v1-standard-1", "metadata": { "ci_managed": "yes" } @@ -30,17 +32,30 @@ "provisioners": [ { "type": "shell", - "environment_vars": [ - "os_branch=stable/rocky", - "rdo_branch=rocky" - ], "scripts": [ - "provision/baseline.sh", - "provision/devstack-pre-pip.sh", - "provision/system_reseal_local_env.sh", - "provision/system_reseal.sh" + "common-packer/provision/install-python.sh" ], "execute_command": "chmod +x {{ .Path }}; if [ \"$UID\" == \"0\" ]; then {{ .Vars }} '{{ .Path }}'; else {{ .Vars }} sudo -E '{{ .Path }}'; fi" + }, + { + "type": "shell-local", + "command": "./common-packer/ansible-galaxy.sh {{user `ansible_roles_path`}}" + }, + { + "type": "ansible", + "playbook_file": "provision/devstack-pre-pip.yaml", + "ansible_env_vars": [ + "ANSIBLE_DEBUG=False", + "ANSIBLE_NOCOWS=1", + "ANSIBLE_PIPELINING=True", + "ANSIBLE_ROLES_PATH={{user `ansible_roles_path`}}", + "ANSIBLE_CALLBACK_WHITELIST=profile_tasks", + "ANSIBLE_STDOUT_CALLBACK=debug" + ], + "extra_arguments": [ + "--extra-vars", + "os_branch=stable/rocky rdo_branch=rocky" + ] } ] } diff --git a/packer/templates/devstack.json b/packer/templates/devstack.json index 4361140ec..274f95c17 100644 --- a/packer/templates/devstack.json +++ b/packer/templates/devstack.json @@ -1,5 +1,6 @@ { "variables": { + "ansible_roles_path": ".galaxy", "base_image": null, "distro": null, "cloud_network": null, @@ -9,19 +10,20 @@ }, "builders": [ { - "type": "openstack", - "region": "ca-ymq-1", - "availability_zone": "ca-ymq-2", - "ssh_username": "{{user `ssh_user`}}", - "ssh_proxy_host": "{{user `ssh_proxy_host`}}", + "name": "vexxhost", "image_name": "ZZCI - {{user `distro`}} - devstack - {{isotime \"20060102-150405.000\"}}", "instance_name": "{{user `distro`}}-devstack-{{uuid}}", "source_image_name": "{{user `base_image`}}", - "flavor": "v1-standard-1", + "type": "openstack", + "region": "ca-ymq-1", + "availability_zone": "ca-ymq-2", "networks": [ "{{user `cloud_network`}}" ], "user_data_file": "{{user `cloud_user_data`}}", + "ssh_username": "{{user `ssh_user`}}", + "ssh_proxy_host": "{{user `ssh_proxy_host`}}", + "flavor": "v1-standard-1", "metadata": { "ci_managed": "yes" } @@ -31,12 +33,24 @@ { "type": "shell", "scripts": [ - "provision/baseline.sh", - "provision/devstack.sh", - "provision/system_reseal_local_env.sh", - "provision/system_reseal.sh" + "common-packer/provision/install-python.sh" ], "execute_command": "chmod +x {{ .Path }}; if [ \"$UID\" == \"0\" ]; then {{ .Vars }} '{{ .Path }}'; else {{ .Vars }} sudo -E '{{ .Path }}'; fi" + }, + { + "type": "shell-local", + "command": "./common-packer/ansible-galaxy.sh {{user `ansible_roles_path`}}" + }, + { + "type": "ansible", + "playbook_file": "provision/devstack.yaml", + "ansible_env_vars": [ + "ANSIBLE_NOCOWS=1", + "ANSIBLE_PIPELINING=True", + "ANSIBLE_ROLES_PATH={{user `ansible_roles_path`}}", + "ANSIBLE_CALLBACK_WHITELIST=profile_tasks", + "ANSIBLE_STDOUT_CALLBACK=debug" + ] } ] }