Skip to content

Commit 11ca62b

Browse files
committed
Issue geerlingguy#202: Add 'blue' test plugin for chapter 7.
1 parent 1475f1d commit 11ca62b

File tree

6 files changed

+43
-8
lines changed

6 files changed

+43
-8
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22
.vagrant/
33
vagrant_ansible_inventory_default
4+
__pycache__
45
*.cache
56
*.retry
67
test.sh

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ env:
7474
- playbook: solr.yml
7575
distro: ubuntu1604
7676

77+
- playbook: test-plugin.yml
78+
distro: centos7
79+
7780
script:
7881
# Use test shim and run playbook if playbook is provided.
7982
- |

README.md

+13-8
Original file line numberDiff line numberDiff line change
@@ -41,44 +41,49 @@ Here is an outline of all the examples contained in this repository, by chapter:
4141

4242
### Chapter 7
4343

44-
- [`dynamic-inventory`](dynamic-inventory/): Two example dynamic inventory scripts (one in PHP, one in Python) for use with Ansible.
44+
- [`test-plugin`](test-plugin/): A simple test plugin that verifies a given value is representative of the color blue.
45+
- [`collection`](collection/): TODO.
4546

4647
### Chapter 8
4748

49+
- [`dynamic-inventory`](dynamic-inventory/): Two example dynamic inventory scripts (one in PHP, one in Python) for use with Ansible.
50+
51+
### Chapter 9
52+
4853
- [`lamp-infrastructure`](lamp-infrastructure/): A multi-server LAMP-based web application infrastructure focused on high-availability and performance for a LAMP-stack app.
4954
- [`elk`](elk/): A two-server example of the Elasticsearch-Logstash-Kibana stack, which uses one server to store and visualize logs centrally, and another server to send logs via Filebeat.
5055

51-
### Chapter 9
56+
### Chapter 10
5257

5358
- [`deployments`](deployments/): A playbook that deploys a Ruby on Rails application into an environment that runs Passenger and Nginx to handle web requests.
5459
- [`deployments-balancer`](deployments-balancer/): A playbook that handles zero-downtime deployments to webservers running behind an HAProxy load balancer.
5560
- [`deployments-rolling`](deployments-rolling/): A playbook that demonstrates rolling deployments to multiple servers for a Node.js app.
5661

57-
### Chapter 10
62+
### Chapter 11
5863

5964
- N/A
6065

61-
### Chapter 11
66+
### Chapter 12
6267

6368
- [`jenkins`](jenkins/): A playbook that installs and configures Jenkins for CI/CD.
6469

65-
### Chapter 12
70+
### Chapter 13
6671

6772
- [`molecule`](molecule/): A Molecule example used for testing and developing an Ansible playbook, or for testing in a Continuous Integration (CI) environment.
6873
- [`ci.yml` GitHub Actions workflow](.github/workflows/ci.yml): A GitHub Actions workflow which runs the `molecule` example in a CI environment.
6974

70-
### Chapter 13
75+
### Chapter 14
7176

7277
- [`https-self-signed`](https-self-signed/): A playbook that generates self-signed certificates.
7378
- [`https-letsencrypt`](https-letsencrypt/): A playbook that demonstrates automated certificate management with Let's Encrypt and Ansible.
7479
- [`https-nginx-proxy`](https-nginx-proxy/): A playbook that demonstrates proxying HTTPS traffic through Nginx to HTTP backends.
7580

76-
### Chapter 14
81+
### Chapter 15
7782

7883
- [`docker`](docker/): Very simple playbook demonstrating Ansible's ability to manage Docker container images.
7984
- [`docker-hubot`](docker-hubot/): Slightly more involved example of Ansible's ability to manage and run Docker container images.
8085

81-
### Chapter 15
86+
### Chapter 16
8287

8388
- [`kubernetes`](kubernetes/): A playbook that builds a three-node Kubernetes cluster.
8489

test-plugin/main.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
- hosts: all
3+
4+
vars:
5+
my_color_choice: blue
6+
7+
tasks:
8+
- name: "Verify {{ my_color_choice }} is a form of blue."
9+
assert:
10+
that: my_color_choice is blue

test-plugin/test_plugins/blue.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# blue Ansible test plugin definition.
2+
3+
def is_blue(string):
4+
blue_values = ['blue', '#0000ff', '#00f', 'rgb(0,0,255)']
5+
if string in blue_values:
6+
return True
7+
else:
8+
return False
9+
10+
class TestModule(object):
11+
''' custom playbook jinja2 tests '''
12+
13+
def tests(self):
14+
return dict(blue=is_blue)

tests/test-plugin.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
- import_playbook: ../test-plugin/main.yml

0 commit comments

Comments
 (0)