From d587307aaf0661d80f5a2cdf5f161df3638d7832 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Thu, 9 Aug 2018 13:35:53 -0500 Subject: [PATCH] Make integration tests works Split base playbook into two plays The update apt-cache handler from base-repos needs to fire before we run base-server. Split into two plays so that the handler will fire. Fix use of first_found For include_vars, using the lookup version of first_found requires being explicit about the path to search in as well. We also need to use query together with loop to get skip to work right. Extract the list of file locations we look for for distro and platform specific variables into a variable so that we can reuse it instead of copy-pasta. The vim package is vim-nox on ubuntu and vim-minimal on debian. ntpdate only needs to be enabled on boot, it does not need to be immediately started. At least, that's what the old puppet was doing and trying to start it immediately breaks centos integration tests. emacs-nox is emacs23-nox on trusty. Change-Id: If3db276a5f6a8f76d7ce8635da8d2cbc316af341 Depends-On: https://review.openstack.org/588326 --- playbooks/base.yaml | 5 ++++ playbooks/group_vars/all.yaml | 7 +++++ playbooks/roles/base-repos/tasks/main.yaml | 11 +++++--- .../roles/base-server/defaults/main.yaml | 2 -- playbooks/roles/base-server/tasks/RedHat.yaml | 3 +-- playbooks/roles/base-server/tasks/main.yaml | 17 +++++------- playbooks/roles/base-server/vars/Debian.yaml | 2 ++ playbooks/roles/base-server/vars/RedHat.yaml | 4 ++- .../roles/base-server/vars/Ubuntu.trusty.yaml | 5 ++++ playbooks/roles/exim/tasks/main.yaml | 26 ++++++++----------- 10 files changed, 47 insertions(+), 35 deletions(-) create mode 100644 playbooks/roles/base-server/vars/Ubuntu.trusty.yaml diff --git a/playbooks/base.yaml b/playbooks/base.yaml index 814e2f663c..e0509bd169 100644 --- a/playbooks/base.yaml +++ b/playbooks/base.yaml @@ -2,4 +2,9 @@ roles: - users - base-repos + +# Split into two plays so that the update apt cache handler fires +# before we run base-server +- hosts: "!disabled" + roles: - base-server diff --git a/playbooks/group_vars/all.yaml b/playbooks/group_vars/all.yaml index cac3158d80..db608c86f6 100644 --- a/playbooks/group_vars/all.yaml +++ b/playbooks/group_vars/all.yaml @@ -3,6 +3,13 @@ copy_puppet: true manifest: /opt/system-config/production/manifests/site.pp manifest_base: /opt/system-config puppet_logdest: syslog +distro_lookup_path: + - "{{ ansible_facts.distribution }}.{{ ansible_facts.lsb.codename }}.{{ ansible_facts.architecture }}.yaml" + - "{{ ansible_facts.distribution }}.{{ ansible_facts.lsb.codename }}.yaml" + - "{{ ansible_facts.distribution }}.{{ ansible_facts.architecture }}.yaml" + - "{{ ansible_facts.distribution }}.yaml" + - "{{ ansible_facts.os_family }}.yaml" + - default.yaml puppet: logdest: syslog diff --git a/playbooks/roles/base-repos/tasks/main.yaml b/playbooks/roles/base-repos/tasks/main.yaml index 779f0614b3..ca15dce871 100644 --- a/playbooks/roles/base-repos/tasks/main.yaml +++ b/playbooks/roles/base-repos/tasks/main.yaml @@ -1,6 +1,9 @@ - name: Set up additional repos - include_tasks: "{{ lookup('first_found', file_list) }}" + include_tasks: "{{ item }}" vars: - file_list: - - "{{ ansible_facts.distribution }}.yaml" - - "{{ ansible_facts.os_family }}.yaml" + params: + files: + - "{{ ansible_facts.distribution }}.yaml" + - "{{ ansible_facts.os_family }}.yaml" + skip: true + loop: "{{ query('first_found', params) }}" diff --git a/playbooks/roles/base-server/defaults/main.yaml b/playbooks/roles/base-server/defaults/main.yaml index 4c297ef319..394dab26ad 100644 --- a/playbooks/roles/base-server/defaults/main.yaml +++ b/playbooks/roles/base-server/defaults/main.yaml @@ -2,7 +2,6 @@ bastion_ipv4: 23.253.245.198,23.253.234.219 bastion_ipv6: 2001:4800:7818:101:3c21:a454:23ed:4072,2001:4800:7817:103:be76:4eff:fe04:5a1d base_packages: - at - - emacs-nox - git - lvm2 - parted @@ -10,5 +9,4 @@ base_packages: - rsyslog - strace - tcpdump - - vim-nox - wget diff --git a/playbooks/roles/base-server/tasks/RedHat.yaml b/playbooks/roles/base-server/tasks/RedHat.yaml index f747f1982b..174fd7c333 100644 --- a/playbooks/roles/base-server/tasks/RedHat.yaml +++ b/playbooks/roles/base-server/tasks/RedHat.yaml @@ -7,7 +7,6 @@ service: name: ntpdate enabled: yes - state: running - name: Configure yum cron copy: @@ -19,4 +18,4 @@ service: name: yum-cron enabled: yes - state: running + state: started diff --git a/playbooks/roles/base-server/tasks/main.yaml b/playbooks/roles/base-server/tasks/main.yaml index d305d4f9d9..b7ae08dc8f 100644 --- a/playbooks/roles/base-server/tasks/main.yaml +++ b/playbooks/roles/base-server/tasks/main.yaml @@ -5,13 +5,12 @@ loop: '{{ base_packages }}' - name: Include OS-specific variables - include_vars: "{{ lookup('first_found', file_list) }}" + include_vars: "{{ lookup('first_found', params) }}" vars: - file_list: - - "{{ ansible_facts.distribution }}.{{ ansible_facts.architecture }}.yaml" - - "{{ ansible_facts.distribution }}.yaml" - - "{{ ansible_facts.os_family }}.yaml" - - "default.yaml" + params: + files: "{{ distro_lookup_path }}" + paths: + - 'vars' - name: Install distro specific packages package: @@ -56,8 +55,4 @@ - name: Include OS-specific tasks include_tasks: "{{ lookup('first_found', file_list) }}" vars: - file_list: - - "{{ ansible_facts.distribution }}.{{ ansible_facts.lsb.codename }}.{{ ansible_facts.architecture }}.yaml" - - "{{ ansible_facts.distribution }}.{{ ansible_facts.architecture }}.yaml" - - "{{ ansible_facts.distribution }}.yaml" - - "{{ ansible_facts.os_family }}.yaml" + file_list: "{{ distro_lookup_path }}" diff --git a/playbooks/roles/base-server/vars/Debian.yaml b/playbooks/roles/base-server/vars/Debian.yaml index d6e870666f..7ad2e9e6c1 100644 --- a/playbooks/roles/base-server/vars/Debian.yaml +++ b/playbooks/roles/base-server/vars/Debian.yaml @@ -1,3 +1,5 @@ distro_packages: - dnsutils + - emacs-nox - iputils-ping + - vim-nox diff --git a/playbooks/roles/base-server/vars/RedHat.yaml b/playbooks/roles/base-server/vars/RedHat.yaml index b7c79ba837..b9d400d471 100644 --- a/playbooks/roles/base-server/vars/RedHat.yaml +++ b/playbooks/roles/base-server/vars/RedHat.yaml @@ -1,9 +1,11 @@ -- distro_packages: +distro_packages: - bind-utils + - emacs-nox - iputils # Utils in ntp-perl are included in Debian's ntp package; we # add it here for consistency. See also # https://tickets.puppetlabs.com/browse/MODULES-3660 - ntp-perl - ntpdate + - vim-minimal - yum-cron diff --git a/playbooks/roles/base-server/vars/Ubuntu.trusty.yaml b/playbooks/roles/base-server/vars/Ubuntu.trusty.yaml new file mode 100644 index 0000000000..e4af7be421 --- /dev/null +++ b/playbooks/roles/base-server/vars/Ubuntu.trusty.yaml @@ -0,0 +1,5 @@ +distro_packages: + - dnsutils + - emacs23-nox + - iputils-ping + - vim-nox diff --git a/playbooks/roles/exim/tasks/main.yaml b/playbooks/roles/exim/tasks/main.yaml index c3d6a43935..db49c9b43f 100644 --- a/playbooks/roles/exim/tasks/main.yaml +++ b/playbooks/roles/exim/tasks/main.yaml @@ -1,22 +1,18 @@ - name: Include OS-specific variables - include_vars: "{{ lookup('first_found', file_list) }}" - vars: - file_list: - - "{{ ansible_facts.distribution }}.{{ ansible_facts.architecture }}.yaml" - - "{{ ansible_facts.distribution }}.yaml" - - "{{ ansible_facts.os_family }}.yaml" - - "default.yaml" - -- name: Include OS-specific tasks - include_tasks: "{{ lookup('first_found', params) }}" + include_vars: "{{ lookup('first_found', params) }}" vars: params: - files: - - "{{ ansible_facts.distribution }}.{{ ansible_facts.lsb.codename }}.{{ ansible_facts.architecture }}.yaml" - - "{{ ansible_facts.distribution }}.{{ ansible_facts.architecture }}.yaml" - - "{{ ansible_facts.distribution }}.yaml" - - "{{ ansible_facts.os_family }}.yaml" + files: "{{ distro_lookup_path }}" + paths: + - 'vars' + +- name: Include OS-specific tasks + include_tasks: "{{ item }}" + vars: + params: + files: "{{ distro_lookup_path }}" skip: true + loop: "{{ query('first_found', params) }}" - name: Install Exim package: