From ed458726a04af79302e608ce85c3e48f8ac27741 Mon Sep 17 00:00:00 2001 From: Sebastian Brandt <793580+sebbrandt87@users.noreply.github.com> Date: Fri, 26 Apr 2019 11:28:44 +0200 Subject: [PATCH] fix: updated test_requirements, corrected linting, correct ec2 parameter to wait for instances to be started updated Jenkinsfile with pip install test_requirements already in the first step on one agent --- Jenkinsfile | 2 +- molecule/ec2/create.yml | 10 +++++----- roles/DCOS.agent/tasks/main.yml | 2 ++ roles/DCOS.bootstrap/tasks/main.yml | 14 +++++++++++--- roles/DCOS.master/tasks/dcos_upgrade.yml | 6 +++++- roles/DCOS.master/tasks/main.yml | 2 ++ test_requirements.txt | 6 +++--- 7 files changed, 29 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d7476793..8ae6d637 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,7 +27,7 @@ pipeline { } steps { retry(3) { - sh("pip install ansible-lint==4.0.1 yamllint==1.11.1") + sh("pip install -r test_requirements.txt") } sh("yamllint -c .yamllint.yml .") sh("ansible-lint roles/") diff --git a/molecule/ec2/create.yml b/molecule/ec2/create.yml index 7354397c..948ced1a 100644 --- a/molecule/ec2/create.yml +++ b/molecule/ec2/create.yml @@ -90,7 +90,7 @@ instance: "{{ item.name }}" molecule_region: "{{ item.region }}" molecule_ssh_user: "{{ item.ssh_user | default(ssh_user) }}" - wait: true + wait: yes exact_count: 1 count_tag: instance: "{{ item.name }}" @@ -113,9 +113,9 @@ set_fact: instance_conf_dict: { 'instance': "{{ item.instances[0].tags.instance }}", - 'region': "{{ item.instances[0].tags['molecule_region'] }}", + 'region': "{{ item.instances[0].tags.molecule_region }}", 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ item.instances[0].tags['molecule_ssh_user'] }}", + 'user': "{{ item.instances[0].tags.molecule_ssh_user }}", 'port': "{{ ssh_port }}", 'identity_file': "{{ keypair_path }}", 'instance_ids': "{{ item.instance_ids }}", } @@ -136,10 +136,10 @@ - name: Wait for SSH wait_for: - port: "{{ ssh_port }}" + port: "{{ item.port }}" host: "{{ item.address }}" search_regex: SSH - delay: 10 + delay: 60 timeout: 320 with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" diff --git a/roles/DCOS.agent/tasks/main.yml b/roles/DCOS.agent/tasks/main.yml index 34ecd622..8a03e9b2 100755 --- a/roles/DCOS.agent/tasks/main.yml +++ b/roles/DCOS.agent/tasks/main.yml @@ -24,6 +24,7 @@ # Same version config updates for nodes that are on the same version, but differ in `dcos-config--setup` package version - name: "Same version config update? Register latest DC/OS-config--setup version from bootstrap" shell: | + set -o pipefail curl {{ dcos['config']['bootstrap_url'] }}/{{ dcos_version_specifier }}/genconf/serve/package_lists/$(curl {{ dcos['config']['bootstrap_url'] }}/{{ dcos_version_specifier }}/genconf/serve/cluster-package-list.latest).package_list.json | \ jq -r '.[] | select(.|test("dcos-config--setup"))' | sed s/dcos-config--// args: @@ -33,6 +34,7 @@ - name: "Same version config update? Is latest DC/OS-config--setup package installed?" shell: | + set -o pipefail /opt/mesosphere/bin/dcos-path/dcos-shell pkgpanda list | grep {{ latest_dcos_config_setup.stdout }} args: executable: bash diff --git a/roles/DCOS.bootstrap/tasks/main.yml b/roles/DCOS.bootstrap/tasks/main.yml index cf5faa99..e1528cc0 100755 --- a/roles/DCOS.bootstrap/tasks/main.yml +++ b/roles/DCOS.bootstrap/tasks/main.yml @@ -61,8 +61,14 @@ - name: Purge old upgrade directory file: - path: "{{ download_path }}/genconf/serve" + path: "{{ download_path }}/genconf/serve/*" state: absent + when: "dcos['version'] is version('1.9', '>=')" + loop: > + {{ groups['dcos'] | default([]) | map('extract',hostvars,'ansible_local')| list | + select('defined') | selectattr('dcos_installation', 'defined') | + map(attribute='dcos_installation') | map(attribute='version') | list | + union([dcos['version_to_upgrade_from'] | default(dcos['version']) ]) | unique }} - name: Ceate install directory/genconf file: path={{ download_path }}/genconf state=directory mode=0755 @@ -171,7 +177,9 @@ union([dcos['version_to_upgrade_from'] | default(dcos['version']) ]) | unique }} - name: Get upgrade directory hash - shell: "ls -td -- */ | head -n 1 | cut -d'/' -f1" + shell: | + set -o pipefail + ls -td -- */ | head -n 1 | cut -d'/' -f1 args: chdir: "{{ download_path }}/genconf/serve/upgrade_from_{{ item }}" changed_when: false @@ -189,7 +197,7 @@ src: "{{ item.stdout }}" state: link when: "dcos['version'] is version('1.9', '>=')" - loop: "{{upgrade_dir_hash.results}}" + loop: "{{ upgrade_dir_hash.results }}" # vvv serve files via http vvv diff --git a/roles/DCOS.master/tasks/dcos_upgrade.yml b/roles/DCOS.master/tasks/dcos_upgrade.yml index 198a0f0e..cf670769 100644 --- a/roles/DCOS.master/tasks/dcos_upgrade.yml +++ b/roles/DCOS.master/tasks/dcos_upgrade.yml @@ -29,6 +29,7 @@ # Step 1 on upgrading prcedure - name: "Upgrade: Check for all-green Exhibitor status" shell: | + set -o pipefail curl --silent http://localhost:8181/exhibitor/v1/cluster/status | jq -r '.[].description' | uniq args: warn: false # Curl inside shell is what we need, silence warning. @@ -50,7 +51,9 @@ port: 5050 delay: 10 - name: "Upgrade: Check for mesos-master systemd unit to be 'running'" - shell: systemctl status dcos-mesos-master | grep '(running)' + shell: | + set -o pipefail + systemctl status dcos-mesos-master | grep '(running)' args: warn: false # We are not interested in changing the state itself, just if it's 'running' retries: 12 @@ -60,6 +63,7 @@ # Step 5 on upgrading procedure - name: "Upgrade: Check for CockrockDB replication status (Enterprise only)" shell: | + set -o pipefail /opt/mesosphere/bin/cockroach node status --ranges --certs-dir=/run/dcos/pki/cockroach --host=$(/opt/mesosphere/bin/detect_ip) --format tsv 2>/dev/null | tail -n+2 | head -n-1 | cut -f 10 | uniq retries: 12 delay: 10 diff --git a/roles/DCOS.master/tasks/main.yml b/roles/DCOS.master/tasks/main.yml index 076e3474..6d886a79 100755 --- a/roles/DCOS.master/tasks/main.yml +++ b/roles/DCOS.master/tasks/main.yml @@ -24,6 +24,7 @@ # Same version config updates for nodes that are on the same version, but differ in `dcos-config--setup` package version - name: "Same version config update? Register latest DC/OS-config--setup version from bootstrap" shell: | + set -o pipefail curl {{ dcos['config']['bootstrap_url'] }}/{{ dcos_version_specifier }}/genconf/serve/package_lists/$(curl {{ dcos['config']['bootstrap_url'] }}/{{ dcos_version_specifier }}/genconf/serve/cluster-package-list.latest).package_list.json | \ jq -r '.[] | select(.|test("dcos-config--setup"))' | sed s/dcos-config--// args: @@ -33,6 +34,7 @@ - name: "Same version config update? Is latest DC/OS-config--setup package installed?" shell: | + set -o pipefail /opt/mesosphere/bin/dcos-path/dcos-shell pkgpanda list | grep {{ latest_dcos_config_setup.stdout }} args: executable: bash diff --git a/test_requirements.txt b/test_requirements.txt index b25db43a..29d75b2d 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -1,7 +1,7 @@ -molecule==2.19.0 +molecule==2.20.1 molecule[ec2] molecule[vagrant] boto boto3 -ansible-lint==4.0.1 -yamllint==1.11.1 +ansible-lint==4.1.0 +yamllint==1.15.0