summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xci/files/install-lib.sh40
-rwxr-xr-xxci/infra/bifrost/scripts/bifrost-provision.sh11
-rw-r--r--xci/installer/kubespray/playbooks/configure-opnfvhost.yml12
-rw-r--r--xci/installer/osa/playbooks/configure-opnfvhost.yml59
-rw-r--r--xci/playbooks/configure-localhost.yml1
-rw-r--r--xci/playbooks/get-opnfv-scenario-requirements.yml25
-rw-r--r--xci/playbooks/roles/bootstrap-host/tasks/network.yml10
-rw-r--r--xci/playbooks/roles/bootstrap-host/tasks/time.yml5
-rw-r--r--xci/playbooks/roles/configure-nfs/tasks/main.yml2
-rw-r--r--xci/playbooks/roles/prepare-functest/tasks/main.yml2
-rwxr-xr-xxci/xci-deploy.sh8
11 files changed, 140 insertions, 35 deletions
diff --git a/xci/files/install-lib.sh b/xci/files/install-lib.sh
index 48233968..92d1f065 100644
--- a/xci/files/install-lib.sh
+++ b/xci/files/install-lib.sh
@@ -135,12 +135,50 @@ function install_ansible() {
set -u
# We are inside the virtualenv now so we should be good to use pip and python from it.
- pip -q install --upgrade -c $uc ara virtualenv pip setuptools ansible==$XCI_ANSIBLE_PIP_VERSION
+ pip -q install --upgrade -c $uc ara virtualenv pip setuptools ansible==$XCI_ANSIBLE_PIP_VERSION ansible-lint==3.4.21
ara_location=$(python -c "import os,ara; print(os.path.dirname(ara.__file__))")
export ANSIBLE_CALLBACK_PLUGINS="/etc/ansible/roles/plugins/callback:${ara_location}/plugins/callbacks"
}
+ansible_lint() {
+ set -eu
+ # Use the upper-constraints file from the pinned requirements repository.
+ local requirements_sha=$(awk '/requirements_git_install_branch:/ {print $2}' ${XCI_PATH}/xci/installer/osa/files/openstack_services.yml)
+ local uc="https://raw.githubusercontent.com/openstack/requirements/${requirements_sha}/upper-constraints.txt"
+ local playbooks_dir=(xci/playbooks xci/installer/osa/playbooks xci/installer/kubespray/playbooks)
+ # Extract role from scenario information
+ local testing_role=$(sed -n "/^- scenario: ${DEPLOY_SCENARIO}/,/^$/p" ${XCI_PATH}/xci/opnfv-scenario-requirements.yml | grep role | rev | cut -d '/' -f -1 | rev)
+
+ # Clone OSA rules too
+ git clone --quiet --depth 1 https://github.com/openstack/openstack-ansible-tests.git \
+ ${XCI_CACHE}/repos/openstack-ansible-tests
+
+ # Because of https://github.com/willthames/ansible-lint/issues/306, ansible-lint does not understand
+ # import and includes yet so we need to trick it with a fake playbook so we can test our roles. We
+ # only test the role for the scenario we are testing
+ echo "Building testing playbook for role: ${testing_role}"
+ cat > ${XCI_PATH}/xci/playbooks/test-playbook.yml << EOF
+ - name: Testing playbook
+ hosts: localhost
+ roles:
+ - ${testing_role}
+EOF
+
+ # Only check our own playbooks
+ for dir in ${playbooks_dir[@]}; do
+ for play in $(ls ${XCI_PATH}/${dir}/*.yml); do
+ echo -en "Checking '${play}' playbook..."
+ ansible-lint --nocolor -R -r \
+ ${XCI_CACHE}/repos/openstack-ansible-tests/ansible-lint ${play}
+ echo -en "[OK]\n"
+ done
+ done
+
+ # Remove testing playbook
+ rm ${XCI_PATH}/xci/playbooks/test-playbook.yml
+}
+
collect_xci_logs() {
echo "----------------------------------"
echo "Info: Collecting XCI logs"
diff --git a/xci/infra/bifrost/scripts/bifrost-provision.sh b/xci/infra/bifrost/scripts/bifrost-provision.sh
index 2d773227..2b849e34 100755
--- a/xci/infra/bifrost/scripts/bifrost-provision.sh
+++ b/xci/infra/bifrost/scripts/bifrost-provision.sh
@@ -10,6 +10,13 @@
set -eu
set -o pipefail
+# This is normally passed from the XCI deployment script but
+# we also need it here for the bifrost jobs which run outside of XCI
+export XCI_PATH="${XCI_PATH:-$(git rev-parse --show-toplevel)}"
+# Declare our virtualenv
+export XCI_VENV="${XCI_VENV:-${XCI_PATH}/venv/}"
+export XCI_DISTRO=${XCI_DISTRO:-$(source /etc/os-release &>/dev/null || source /usr/lib/os-release &>/dev/null; echo ${ID,,})}
+
export PYTHONUNBUFFERED=1
SCRIPT_HOME="$(cd "$(dirname "$0")" && pwd)"
BIFROST_HOME=$SCRIPT_HOME/..
@@ -25,10 +32,6 @@ BIFROST_IRONIC_INSPECTOR_CLIENT_VERSION=${BIFROST_IRONIC_INSPECTOR_CLIENT_VERSIO
BIFROST_IRONIC_CLIENT_VERSION=${BIFROST_IRONIC_CLIENT_VERSION:-master}
BIFROST_IRONIC_VERSION=${BIFROST_IRONIC_VERSION:-master}
-# This is normally passed from the XCI deployment script but
-# we also need it here for the bifrost jobs which run outside of XCI
-export XCI_DISTRO=${XCI_DISTRO:-$(source /etc/os-release &>/dev/null || source /usr/lib/os-release &>/dev/null; echo ${ID,,})}
-
# set UPPER_CONSTRAINTS_FILE since it is needed in order to limit libvirt-python to 4.0.0
export UPPER_CONSTRAINTS_FILE=https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt
diff --git a/xci/installer/kubespray/playbooks/configure-opnfvhost.yml b/xci/installer/kubespray/playbooks/configure-opnfvhost.yml
index 8166b0e5..eed814ba 100644
--- a/xci/installer/kubespray/playbooks/configure-opnfvhost.yml
+++ b/xci/installer/kubespray/playbooks/configure-opnfvhost.yml
@@ -31,7 +31,7 @@
delete: yes
- name: generate SSH keys
- shell: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""
+ command: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""
args:
creates: /root/.ssh/id_rsa
- name: add id_rsa.pub to authorized_keys
@@ -47,15 +47,19 @@
path: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory"
state: absent
- name: copy kubespray inventory directory
- shell: "cp -rf {{ remote_xci_flavor_files }}/inventory \
+ command: "cp -rf {{ remote_xci_flavor_files }}/inventory \
{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory"
+ args:
+ creates: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory"
- name: make sure kubespray/opnfv_inventory/group_vars/ exist
file:
path: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory/group_vars"
state: directory
- name: copy k8s_cluster.yml
- shell: "cp -rf {{ remote_xci_path }}/xci/installer/kubespray/files/k8s-cluster.yml \
+ command: "cp -rf {{ remote_xci_path }}/xci/installer/kubespray/files/k8s-cluster.yml \
{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory/group_vars"
+ args:
+ creates: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory/group_vars"
- name: Install required packages
package:
name: "{{ kube_require_packages[ansible_pkg_mgr] }}"
@@ -82,3 +86,5 @@
tasks:
- name: Append public keys to authorized_keys
shell: "/bin/cat {{ ansible_env.HOME }}/.ssh/id_rsa.pub >> {{ xci_path }}/xci/files/authorized_keys"
+ args:
+ creates: "{{ xci_path }}/xci/files/authorized_keys"
diff --git a/xci/installer/osa/playbooks/configure-opnfvhost.yml b/xci/installer/osa/playbooks/configure-opnfvhost.yml
index 2485f477..001fcee3 100644
--- a/xci/installer/osa/playbooks/configure-opnfvhost.yml
+++ b/xci/installer/osa/playbooks/configure-opnfvhost.yml
@@ -44,9 +44,10 @@
tasks:
- name: generate SSH keys
- shell: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""
+ command: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""
args:
creates: "{{ ansible_env.HOME }}/.ssh/id_rsa"
+ changed_when: True
- name: fetch public key
fetch:
src: "{{ ansible_env.HOME }}/.ssh/id_rsa.pub"
@@ -59,17 +60,27 @@
recursive: yes
delete: yes
- name: copy flavor inventory
- shell: "/bin/cp -rf {{ remote_xci_flavor_files }}/inventory {{ remote_xci_playbooks }}"
+ command: "/bin/cp -rf {{ remote_xci_flavor_files }}/inventory {{ remote_xci_playbooks }}"
+ args:
+ creates: "{{ remote_xci_playbooks }}/inventory"
- name: copy openstack_deploy
- shell: "/bin/cp -rf {{openstack_osa_path}}/etc/openstack_deploy {{openstack_osa_etc_path}}"
+ command: "/bin/cp -rf {{openstack_osa_path}}/etc/openstack_deploy {{openstack_osa_etc_path}}"
+ args:
+ creates: "{{ openstack_osa_etc_path }}"
- name: copy openstack_user_config.yml
- shell: "/bin/cp -rf {{ remote_xci_flavor_files }}/openstack_user_config.yml {{openstack_osa_etc_path}}"
+ command: "/bin/cp -rf {{ remote_xci_flavor_files }}/openstack_user_config.yml {{openstack_osa_etc_path}}"
+ args:
+ creates: "{{ openstack_osa_etc_path }}/openstack_user_config.yml"
failed_when: false
- name: copy all user override files
- shell: "/bin/cp -rf {{ remote_xci_flavor_files }}/user_variables.yml {{openstack_osa_etc_path}}"
+ command: "/bin/cp -rf {{ remote_xci_flavor_files }}/user_variables.yml {{openstack_osa_etc_path}}"
+ args:
+ creates: "{{ openstack_osa_etc_path }}/user_variables.yml }}"
failed_when: false
- name: copy cinder.yml
- shell: "/bin/cp -rf {{ remote_xci_path }}/xci/installer/osa/files/cinder.yml {{openstack_osa_etc_path}}/env.d"
+ command: "/bin/cp -rf {{ remote_xci_path }}/xci/installer/osa/files/cinder.yml {{openstack_osa_etc_path}}/env.d"
+ args:
+ creates: "{{ openstack_osa_etc_path }}/env.d/cinder.yml"
- name: Configure OpenStack-Ansible components
lineinfile:
path: "{{ openstack_osa_etc_path }}/user_variables.yml"
@@ -81,15 +92,23 @@
- { component: "core_openstack", value: "{{ core_openstack_install | bool }}" }
- block:
- name: copy ceph.yml
- shell: "/bin/cp -rf {{ remote_xci_flavor_files }}/ceph.yml {{openstack_osa_etc_path}}/conf.d/"
+ command: "/bin/cp -rf {{ remote_xci_flavor_files }}/ceph.yml {{openstack_osa_etc_path}}/conf.d/"
+ args:
+ creates: "{{ openstack_osa_etc_path }}/conf.d/ceph.yml"
- name: copy user_ceph.yml
- shell: "/bin/cp -rf {{ remote_xci_flavor_files }}/user_ceph.yml {{openstack_osa_etc_path}}/user_ceph.yml"
+ command: "/bin/cp -rf {{ remote_xci_flavor_files }}/user_ceph.yml {{openstack_osa_etc_path}}/user_ceph.yml"
+ args:
+ creates: "{{ openstack_osa_etc_path }}/user_ceph.yml"
- name: copy user_variables_ceph.yml
- shell: "/bin/cp -rf {{ remote_xci_flavor_files }}/user_variables_ceph.yml {{openstack_osa_etc_path}}/user_variables_ceph.yml"
+ command: "/bin/cp -rf {{ remote_xci_flavor_files }}/user_variables_ceph.yml {{openstack_osa_etc_path}}/user_variables_ceph.yml"
+ args:
+ creates: "{{ openstack_osa_etc_path }}/user_variables_ceph.yml"
when: xci_ceph_enabled == "true"
- block:
- name: copy user_variables_proxy.yml
- shell: "/bin/cp -rf {{ remote_xci_path }}/xci/installer/osa/files/user_variables_proxy.yml {{openstack_osa_etc_path}}/user_variables_proxy.yml"
+ command: "/bin/cp -rf {{ remote_xci_path }}/xci/installer/osa/files/user_variables_proxy.yml {{openstack_osa_etc_path}}/user_variables_proxy.yml"
+ args:
+ creates: "{{ openstack_osa_etc_path }}/user_variables_proxy.yml"
- name: "Configure http_proxy_env_url"
lineinfile:
path: "{{openstack_osa_etc_path}}/user_variables_proxy.yml"
@@ -98,21 +117,28 @@
when:
- lookup('env','http_proxy') != "randomfoobarstring"
- name: copy OPNFV OpenStack playbook
- shell: "/bin/cp -rf {{ remote_xci_path }}/xci/installer/osa/files/setup-openstack.yml {{openstack_osa_path}}/playbooks"
+ command: "/bin/cp -rf {{ remote_xci_path }}/xci/installer/osa/files/setup-openstack.yml {{openstack_osa_path}}/playbooks"
+ args:
+ creates: "{{ openstack_osa_path }}/playbooks/setup-openstack.yml"
- name: copy pinned versions of OSA Roles and global requirements
- shell: "/bin/cp -rf {{ remote_xci_path }}/xci/installer/osa/files/{{ item }} {{openstack_osa_path}}/{{ item }}"
+ command: "/bin/cp -rf {{ remote_xci_path }}/xci/installer/osa/files/{{ item }} {{openstack_osa_path}}/{{ item }}"
+ args:
+ creates: "{{ openstack_osa_path }}/{{ item }}"
with_items:
- "ansible-role-requirements.yml"
- "global-requirement-pins.txt"
when:
- openstack_osa_version != "master"
- name: copy pinned versions of OpenStack services
- shell: "/bin/cp -rf {{ remote_xci_path }}/xci/installer/osa/files/openstack_services.yml {{openstack_osa_path}}/playbooks/defaults/repo_packages/openstack_services.yml"
+ command: "/bin/cp -rf {{ remote_xci_path }}/xci/installer/osa/files/openstack_services.yml {{openstack_osa_path}}/playbooks/defaults/repo_packages/openstack_services.yml"
+ args:
+ creates: "{{ openstack_osa_path }}/playbooks/defaults/repo_packages/openstack_services.yml"
when:
- openstack_osa_version != "master"
- include: "{{ xci_path }}/xci/playbooks/bootstrap-scenarios.yml"
- name: bootstrap ansible on opnfv host
command: "/bin/bash ./scripts/bootstrap-ansible.sh"
+ changed_when: True
args:
chdir: "{{openstack_osa_path}}"
- name: install opnfv pip required packages
@@ -131,9 +157,8 @@
extra_args: '-c https://raw.githubusercontent.com/openstack/requirements/{{ requirements_git_install_branch }}/upper-constraints.txt'
executable: '/opt/ansible-runtime/bin/pip'
- name: Determine ARA callback location
- shell: "/opt/ansible-runtime/bin/python -c 'import os,ara; print(os.path.dirname(ara.__file__))'"
- args:
- executable: /bin/bash
+ command: "/opt/ansible-runtime/bin/python -c 'import os,ara; print(os.path.dirname(ara.__file__))'"
+ changed_when: False
register: _ara_install_dir
- name: Create local Ansible plugins directory
file:
@@ -149,6 +174,7 @@
command: "python pw-token-gen.py --file {{openstack_osa_etc_path}}/user_secrets.yml"
args:
chdir: "{{openstack_osa_path}}/scripts"
+ changed_when: True
- name: check if certificate directory /etc/ssl/certs exists already
stat: path=/etc/ssl/certs
register: check_etc_ssl_certs
@@ -184,6 +210,7 @@
tasks:
- name: Append public keys to authorized_keys
shell: "/bin/cat {{ ansible_env.HOME }}/.ssh/id_rsa.pub >> {{ xci_path }}/xci/files/authorized_keys"
+ changed_when: True
- hosts: opnfv
remote_user: root
diff --git a/xci/playbooks/configure-localhost.yml b/xci/playbooks/configure-localhost.yml
index c8a9840c..f64400e3 100644
--- a/xci/playbooks/configure-localhost.yml
+++ b/xci/playbooks/configure-localhost.yml
@@ -103,3 +103,4 @@
shell: env > "{{ xci_path }}/.cache/xci.env"
args:
executable: /bin/bash
+ creates: "{{ xci_path }}/.cache/xci.env"
diff --git a/xci/playbooks/get-opnfv-scenario-requirements.yml b/xci/playbooks/get-opnfv-scenario-requirements.yml
index 73590820..f37de61a 100644
--- a/xci/playbooks/get-opnfv-scenario-requirements.yml
+++ b/xci/playbooks/get-opnfv-scenario-requirements.yml
@@ -68,7 +68,7 @@
- name: Plug in the scenario to XCI
synchronize:
src: "{{ scenario_path_default }}/{{ item.item.scenario }}/{{ item.item.role }}/"
- dest: "{{ role_path_default }}/{{ item.item.scenario }}"
+ dest: "{{ role_path_default }}/{{ item.item.role | basename }}"
when: item.stat.exists
with_items: "{{ scenarios_list_exists.results }}"
loop_control:
@@ -76,8 +76,16 @@
- name: Synchronize local changes to scenarios' master branch
synchronize:
- src: "{{ xci_path }}/xci/scenarios/{{ item.item.scenario }}/{{ item.item.role | replace('xci/scenarios/{{ item.item.scenario }}', '') }}/"
- dest: "{{ role_path_default }}/{{ item.item.scenario }}"
+ src: "{{ xci_path }}/xci/scenarios/{{ item.item.scenario }}/{{ item.item.role | replace('xci/scenarios/' ~ item.item.scenario ~ '/', '') }}/"
+ dest: "{{ role_path_default }}/{{ item.item.role | basename }}"
+ archive: no
+ times: no
+ recurse: yes
+ checksum: yes
+ owner: yes
+ group: yes
+ perms: yes
+ links: yes
failed_when: false
when:
- item.stat.exists
@@ -89,7 +97,7 @@
- name: Plug in the scenario to XCI (fallback)
synchronize:
src: "{{ xci_path }}/{{ item.item.role }}/"
- dest: "{{ role_path_default }}/{{ item.item.scenario }}"
+ dest: "{{ role_path_default }}/{{ item.item.role | basename }}"
when: not item.stat.exists
with_items: "{{ scenarios_list_exists.results }}"
loop_control:
@@ -105,18 +113,21 @@
- name: Determine if the selected {{ deploy_scenario }} scenario can be deployed
block:
- - set_fact:
+ - name: Set scenario installer fact
+ set_fact:
deploy_scenario_installer: "{{ item }}"
with_items: "{{ deploy_scenario.installers }}"
loop_control:
label: "{{ item.installer }}"
when: item.installer == installer_type
- - set_fact:
+ - name: Set scenario flavor fact
+ set_fact:
deploy_scenario_flavor: "{{ (xci_flavor in deploy_scenario_installer.flavors) | bool }}"
when:
- deploy_scenario_installer is defined
- deploy_scenario_installer
- - set_fact:
+ - name: Set scenario distro flavor fact
+ set_fact:
deploy_scenario_distro: "{{ (xci_distro in deploy_scenario_installer.distros) | bool }}"
when:
- deploy_scenario_flavor is defined
diff --git a/xci/playbooks/roles/bootstrap-host/tasks/network.yml b/xci/playbooks/roles/bootstrap-host/tasks/network.yml
index 01edf459..ea9060e6 100644
--- a/xci/playbooks/roles/bootstrap-host/tasks/network.yml
+++ b/xci/playbooks/roles/bootstrap-host/tasks/network.yml
@@ -37,7 +37,12 @@
name: 8021q
state: present
- name: ensure interfaces.d folder is empty
- shell: "/bin/rm -rf /etc/network/interfaces.d/*"
+ file:
+ state: "{{ item }}"
+ path: "/etc/network/interfaces.d"
+ with_items:
+ - absent
+ - directory
- name: ensure interfaces file is updated
template:
src: "{{ ansible_os_family | lower }}/{{ ansible_hostname }}.interface.j2"
@@ -122,7 +127,8 @@
poll: 0
when: ansible_os_family | lower == "redhat"
-- local_action:
+- name: Wait for host to come back to life
+ local_action:
module: wait_for
host: "{{ ansible_host }}"
delay: 15
diff --git a/xci/playbooks/roles/bootstrap-host/tasks/time.yml b/xci/playbooks/roles/bootstrap-host/tasks/time.yml
index 4b3bf95a..9eca769d 100644
--- a/xci/playbooks/roles/bootstrap-host/tasks/time.yml
+++ b/xci/playbooks/roles/bootstrap-host/tasks/time.yml
@@ -10,13 +10,16 @@
- name: install chrony
package:
name: "chrony"
- state: latest
+ state: present
- name: restart chrony
service:
name: "{{ (ansible_pkg_mgr == 'apt') | ternary('chrony', 'chronyd') }}"
state: restarted
- name: synchronize time
shell: "chronyc -a 'burst 4/4' && chronyc -a makestep"
+ args:
+ executable: /bin/bash
+ changed_when: True
register: chrony_got_time
until: chrony_got_time.rc == 0
retries: 5
diff --git a/xci/playbooks/roles/configure-nfs/tasks/main.yml b/xci/playbooks/roles/configure-nfs/tasks/main.yml
index 25e81496..3b349ad6 100644
--- a/xci/playbooks/roles/configure-nfs/tasks/main.yml
+++ b/xci/playbooks/roles/configure-nfs/tasks/main.yml
@@ -47,7 +47,7 @@
- name: Install the NFS server package
package:
name: "{{ nfs_server_package }}"
- state: latest
+ state: present
- name: restart NFS service
service:
diff --git a/xci/playbooks/roles/prepare-functest/tasks/main.yml b/xci/playbooks/roles/prepare-functest/tasks/main.yml
index 2797ce43..ad578bfd 100644
--- a/xci/playbooks/roles/prepare-functest/tasks/main.yml
+++ b/xci/playbooks/roles/prepare-functest/tasks/main.yml
@@ -30,9 +30,11 @@
shell: "ip a | grep {{ gateway_ip }}"
register: gateway_ip_result
ignore_errors: True
+ changed_when: False
- name: add public network gateway
command: "ip addr add {{ gateway_ip_mask }} brd {{ broadcast_ip }} dev {{ gateway_interface }}"
+ changed_when: False
when: gateway_ip_result|failed
- name: prepare environment file for functest
diff --git a/xci/xci-deploy.sh b/xci/xci-deploy.sh
index 618377ec..20f67e61 100755
--- a/xci/xci-deploy.sh
+++ b/xci/xci-deploy.sh
@@ -144,6 +144,14 @@ ansible-playbook ${XCI_ANSIBLE_PARAMS} -i "localhost," get-opnfv-scenario-requir
echo "-------------------------------------------------------------------------"
#-------------------------------------------------------------------------------
+# Check playbooks using ansible-lint
+#-------------------------------------------------------------------------------
+echo "Info: Verifying XCI playbooks using ansible-lint"
+echo "-------------------------------------------------------------------------"
+ansible_lint
+echo "-------------------------------------------------------------------------"
+
+#-------------------------------------------------------------------------------
# Get scenario variables overrides
#-------------------------------------------------------------------------------
source $(find $XCI_SCENARIOS_CACHE/${DEPLOY_SCENARIO} -name xci_overrides) &>/dev/null || :