forked from geerlingguy/ansible-role-varnish
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c79ca2a
commit 4945fda
Showing
17 changed files
with
170 additions
and
114 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,2 +1,3 @@ | ||
*.retry | ||
tests/test.sh | ||
*/__pycache__ | ||
*.pyc |
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,44 +1,36 @@ | ||
--- | ||
language: python | ||
services: docker | ||
|
||
env: | ||
- distro: centos7 | ||
- distro: centos6 | ||
- distro: ubuntu1604 | ||
- distro: ubuntu1404 | ||
- distro: debian9 | ||
- distro: debian8 | ||
|
||
# Also test installing older versions. | ||
- distro: centos7 | ||
playbook: test-41.yml | ||
varnish_version: "4.1" | ||
- distro: ubuntu1604 | ||
varnish_version: "4.1" | ||
playbook: test-41.yml | ||
global: | ||
- ROLE_NAME: varnish | ||
matrix: | ||
- MOLECULE_DISTRO: centos7 | ||
MOLECULE_DOCKER_COMMAND: /usr/lib/systemd/systemd | ||
- MOLECULE_DISTRO: centos6 | ||
- MOLECULE_DISTRO: ubuntu1604 | ||
- MOLECULE_DISTRO: ubuntu1404 | ||
- MOLECULE_DISTRO: debian9 | ||
- MOLECULE_DISTRO: debian8 | ||
|
||
- MOLECULE_DISTRO: centos7 | ||
MOLECULE_DOCKER_COMMAND: /usr/lib/systemd/systemd | ||
MOLECULE_PLAYBOOK: playbook-41.yml | ||
|
||
install: | ||
# Install test dependencies. | ||
- pip install molecule docker | ||
|
||
before_script: | ||
# Use actual Ansible Galaxy role name for the project directory. | ||
- cd ../ | ||
- mv ansible-role-$ROLE_NAME geerlingguy.$ROLE_NAME | ||
- cd geerlingguy.$ROLE_NAME | ||
|
||
script: | ||
# Configure test script so we can run extra tests after playbook is run. | ||
- export container_id=$(date +%s) | ||
- export cleanup=false | ||
|
||
# Download test shim. | ||
- wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/ | ||
- chmod +x ${PWD}/tests/test.sh | ||
|
||
# Run tests. | ||
- ${PWD}/tests/test.sh | ||
|
||
# Make sure Varnish is running. | ||
- 'docker exec --tty ${container_id} env TERM=xterm varnishd -V' | ||
|
||
# Test the version of Varnish installed (default to the main.yml default). | ||
- | | ||
varnish_version="${varnish_version:-5.1}" | ||
docker exec --tty ${container_id} env TERM=xterm varnishd -V | grep "${varnish_version}" | ||
# Test port 80. | ||
- 'docker exec --tty ${container_id} env TERM=xterm curl -sI localhost:80 | grep -q "Via: .* varnish"' | ||
- molecule test | ||
|
||
notifications: | ||
webhooks: https://galaxy.ansible.com/api/v1/notifications/ |
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,6 +1,6 @@ | ||
--- | ||
- name: reload systemd | ||
command: systemctl daemon-reload | ||
systemd: daemon-reload=true | ||
|
||
- name: restart varnish | ||
service: name=varnish state=restarted |
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
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,27 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: docker | ||
lint: | ||
name: yamllint | ||
options: | ||
config-file: molecule/default/yaml-lint.yml | ||
platforms: | ||
- name: instance | ||
image: geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible | ||
command: ${MOLECULE_DOCKER_COMMAND:-"sleep infinity"} | ||
privileged: true | ||
pre_build_image: true | ||
provisioner: | ||
name: ansible | ||
lint: | ||
name: ansible-lint | ||
playbooks: | ||
converge: ${MOLECULE_PLAYBOOK:-playbook.yml} | ||
scenario: | ||
name: default | ||
verifier: | ||
name: testinfra | ||
lint: | ||
name: flake8 |
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,24 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
become: true | ||
|
||
vars: | ||
varnish_version: "4.1" | ||
|
||
pre_tasks: | ||
- import_tasks: playbook-setup.yml | ||
|
||
roles: | ||
- role: geerlingguy.varnish | ||
|
||
post_tasks: | ||
- name: Check the installed Ansible version. | ||
command: varnishd -V | ||
register: varnish_version | ||
failed_when: "'4.1' not in varnish_version.stdout" | ||
|
||
- name: Verify Varnish is running on port 80. | ||
shell: 'curl -sI localhost:80 | grep -q "Via: .* varnish"' | ||
args: | ||
warn: 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,25 @@ | ||
--- | ||
- name: Update apt cache. | ||
apt: update_cache=true cache_valid_time=600 | ||
when: ansible_os_family == 'Debian' | ||
|
||
- name: Ensure build dependencies are installed (RedHat 7+). | ||
yum: | ||
name: | ||
- logrotate | ||
- systemd-sysv | ||
state: present | ||
when: | ||
- ansible_os_family == 'RedHat' | ||
- ansible_distribution_major_version >= '7' | ||
|
||
- name: Ensure build dependencies are installed (RedHat < 7). | ||
yum: | ||
name: logrotate | ||
state: present | ||
when: | ||
- ansible_os_family == 'RedHat' | ||
- ansible_distribution_major_version < '7' | ||
|
||
- name: Ensure curl is installed. | ||
package: name=curl state=present |
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,23 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
become: true | ||
|
||
pre_tasks: | ||
- import_tasks: playbook-setup.yml | ||
|
||
roles: | ||
- role: geerlingguy.varnish | ||
|
||
post_tasks: | ||
- name: Check the installed Ansible version. | ||
command: varnishd -V | ||
register: varnish_version | ||
failed_when: "'5.1' not in varnish_version.stdout" | ||
tags: ['skip_ansible_lint'] | ||
|
||
- name: Verify Varnish is running on port 80. | ||
shell: 'curl -sI localhost:80 | grep -q "Via: .* varnish"' | ||
args: | ||
warn: false | ||
tags: ['skip_ansible_lint'] |
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,14 @@ | ||
import os | ||
|
||
import testinfra.utils.ansible_runner | ||
|
||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( | ||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') | ||
|
||
|
||
def test_hosts_file(host): | ||
f = host.file('/etc/hosts') | ||
|
||
assert f.exists | ||
assert f.user == 'root' | ||
assert f.group == 'root' |
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,6 @@ | ||
--- | ||
extends: default | ||
rules: | ||
line-length: | ||
max: 160 | ||
level: warning |
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
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.