This repository has been archived by the owner on Jun 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Test distributions and versions combinations using [provision_docker](https://github.com/chrismeyersfsu/provision_docker) - Move idempotency check to test playbook - Add variables assertions - Ansible 2.4+ only
- Loading branch information
Showing
10 changed files
with
109 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,13 @@ | ||
--- | ||
language: python | ||
python: "2.7" | ||
sudo: required | ||
dist: trusty | ||
before_install: | ||
- sudo apt-get update -qq | ||
language: python | ||
services: docker | ||
|
||
cache: pip | ||
|
||
install: | ||
- pip install ansible | ||
- "echo localhost > inventory remote_user=root" | ||
- pip install ansible docker | ||
- ansible-galaxy install -r tests/requirements.yml -p tests/roles/ | ||
|
||
script: | ||
- "ansible-playbook -i inventory role.yml --connection=local --sudo" | ||
- > | ||
ansible-playbook -i inventory role.yml --connection=local --sudo | ||
| grep -q 'changed=0.*failed=0' | ||
&& (echo 'Idempotence test: pass' && exit 0) | ||
|| (echo 'Idempotence test: fail' && exit 1) | ||
- > | ||
ansible-playbook -i inventory role.yml --connection=local --sudo | ||
--tags unattended | grep -q 'changed=0.*failed=0' | ||
&& (echo 'Idempotence test: pass' && exit 0) | ||
|| (echo 'Idempotence test: fail' && exit 1) | ||
- apt-config dump | grep 'Unattended-Upgrade "1"' | ||
- sudo unattended-upgrades --dry-run | ||
|
||
notifications: | ||
webhooks: https://galaxy.ansible.com/api/v1/notifications/ | ||
- ansible --version | ||
- tests/test.sh |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[defaults] | ||
roles_path = ../../ | ||
retry_files_enabled = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env python" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
- src: chrismeyersfsu.provision_docker | ||
name: provision_docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
# Exit on any individual command failure | ||
set -e | ||
|
||
# Pretty colors. | ||
red='\033[0;31m' | ||
green='\033[0;32m' | ||
neutral='\033[0m' | ||
|
||
section() { | ||
echo -e "\033[33;1m$1\033[0m" | ||
} | ||
|
||
fold_start() { | ||
echo -e "travis_fold:start:$1\033[33;1m$2\033[0m" | ||
} | ||
|
||
fold_end() { | ||
echo -e "\ntravis_fold:end:$1\r" | ||
} | ||
|
||
# Ensure we are in the tests dir | ||
cd "$( dirname "${BASH_SOURCE[0]}" )" | ||
|
||
section "Syntax check" | ||
ansible-playbook -i inventory --syntax-check test.yml | ||
section "Running role" | ||
ansible-playbook -i inventory test.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
- name: Bring up Docker containers | ||
hosts: localhost | ||
gather_facts: false | ||
vars: | ||
inventory: | ||
- name: ubuntu_rolling | ||
image: "ubuntu:rolling" | ||
- name: ubuntu_latest | ||
image: "ubuntu:latest" | ||
- name: ubuntu_trusty | ||
image: "ubuntu:trusty" | ||
- name: debian_testing | ||
image: "debian:testing" | ||
- name: debian_stable | ||
image: "debian:stable" | ||
- name: debian_oldstable | ||
image: "debian:oldstable" | ||
roles: | ||
- role: provision_docker | ||
provision_docker_inventory: "{{ inventory }}" | ||
provision_docker_privileged: true | ||
provision_docker_use_docker_connection: true | ||
|
||
- name: Test role | ||
hosts: docker_containers | ||
gather_facts: false | ||
pre_tasks: | ||
- name: Provision Python | ||
raw: bash -c "test -e /usr/bin/python || (apt-get -y update && apt-get install -y python-simplejson)" | ||
register: output | ||
changed_when: output.stdout | ||
- setup: # Gather facts | ||
vars: | ||
unattended_autofix_interrupted_dpkg: false | ||
unattended_minimal_steps: true | ||
unattended_install_on_shutdown: true | ||
unattended_automatic_reboot: true | ||
roles: | ||
# Searched for in ../.. (see ansible.cfg) | ||
- ansible-role-unattended-upgrades | ||
tasks: | ||
- name: Idempotency check | ||
include_role: | ||
name: ansible-role-unattended-upgrades | ||
register: idempotency | ||
- fail: | ||
msg: Role failed idempotency check | ||
when: idempotency.changed | ||
|
||
- name: Get apt-config variables | ||
shell: apt-config dump | ||
register: aptconfig | ||
- name: Check for registered variables | ||
assert: | ||
that: item in aptconfig.stdout | ||
with_items: | ||
- 'APT::Periodic::Unattended-Upgrade "1"' | ||
- 'Unattended-Upgrade::AutoFixInterruptedDpkg "false"' | ||
- 'Unattended-Upgrade::MinimalSteps "true"' | ||
- 'Unattended-Upgrade::InstallOnShutdown "true"' | ||
- 'Unattended-Upgrade::Automatic-Reboot "true"' | ||
|
||
- name: Dry run unattended-upgrades | ||
command: /usr/bin/unattended-upgrades --dry-run |