-
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
e55aa80
commit a782a3c
Showing
8 changed files
with
139 additions
and
14 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!groovy | ||
|
||
/* Declarative pipeline */ | ||
pipeline { | ||
agent { | ||
node { | ||
label 'master' | ||
customWorkspace 'workspace/nginx' | ||
} | ||
} | ||
stages { | ||
stage('Prepare environment') { | ||
steps { | ||
sh 'molecule create' | ||
sh 'molecule converge' | ||
} | ||
} | ||
stage('Check syntax') { | ||
steps { | ||
sh 'molecule syntax' | ||
} | ||
} | ||
stage('Run Tests'){ | ||
steps { | ||
sh 'molecule idempotence' | ||
sh 'molecule verify' | ||
} | ||
} | ||
} | ||
|
||
post { | ||
always { | ||
sh 'molecule destroy' | ||
} | ||
success { | ||
mattermostSend color: 'good', message: "Job ${JOB_NAME} ${BUILD_NUMBER} has finished successfully (<${BUILD_URL}|Open>)" | ||
} | ||
failure { | ||
mattermostSend color: 'danger', message: "Job ${JOB_NAME} ${BUILD_NUMBER} has failed(<${BUILD_URL}|Open>)" | ||
} | ||
} | ||
} |
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 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,19 @@ | ||
--- | ||
ansible: | ||
playbook: tests/playbook.yml | ||
driver: | ||
name: docker | ||
verifier: | ||
name: testinfra | ||
docker: | ||
containers: | ||
- name: nginx-ubuntu | ||
image: docker | ||
image_version: xenial | ||
ansible_groups: | ||
- group1 | ||
- name: nginx-centos | ||
image: centos | ||
image_version: 7 | ||
ansible_groups: | ||
- group2 |
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,4 @@ | ||
localhost | ||
[group1] | ||
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,4 @@ | ||
--- | ||
- hosts: all | ||
roles: | ||
- 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,58 @@ | ||
from testinfra.utils.ansible_runner import AnsibleRunner | ||
|
||
testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all') | ||
|
||
|
||
def test_directories(File): | ||
present = [ | ||
"/etc/nginx", | ||
"/etc/nginx/snippets", | ||
"/etc/nginx/sites-enabled", | ||
"/etc/nginx/sites-available" | ||
] | ||
if present: | ||
for directory in present: | ||
d = File(directory) | ||
assert d.is_directory | ||
assert d.exists | ||
|
||
|
||
def test_files(File): | ||
def test_files(File): | ||
present = [ | ||
"/etc/nginx/nginx.conf" | ||
] | ||
absent = [ | ||
"/etc/nginx/sites-enabled/default" | ||
] | ||
if present: | ||
for file in present: | ||
f = File(file) | ||
assert f.exists | ||
assert f.is_file | ||
if absent: | ||
for file in absent: | ||
d = File(file) | ||
assert not d.exists | ||
|
||
|
||
|
||
def test_service(Service): | ||
present = [ | ||
"nginx" | ||
] | ||
if present: | ||
for service in present: | ||
s = Service(service) | ||
assert s.is_running | ||
assert s.is_enabled | ||
|
||
|
||
def test_packages(Package): | ||
present = [ | ||
"nginx" | ||
] | ||
if present: | ||
for package in present: | ||
p = Package(package) | ||
assert p.is_installed |