mirror of
https://github.com/geerlingguy/ansible-for-devops.git
synced 2024-05-19 06:50:03 +00:00
Issue #202: Add 'blue' test plugin for chapter 7.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
.DS_Store
|
||||
.vagrant/
|
||||
vagrant_ansible_inventory_default
|
||||
__pycache__
|
||||
*.cache
|
||||
*.retry
|
||||
test.sh
|
||||
|
@ -74,6 +74,9 @@ env:
|
||||
- playbook: solr.yml
|
||||
distro: ubuntu1604
|
||||
|
||||
- playbook: test-plugin.yml
|
||||
distro: centos7
|
||||
|
||||
script:
|
||||
# Use test shim and run playbook if playbook is provided.
|
||||
- |
|
||||
|
21
README.md
21
README.md
@ -41,44 +41,49 @@ Here is an outline of all the examples contained in this repository, by chapter:
|
||||
|
||||
### Chapter 7
|
||||
|
||||
- [`dynamic-inventory`](dynamic-inventory/): Two example dynamic inventory scripts (one in PHP, one in Python) for use with Ansible.
|
||||
- [`test-plugin`](test-plugin/): A simple test plugin that verifies a given value is representative of the color blue.
|
||||
- [`collection`](collection/): TODO.
|
||||
|
||||
### Chapter 8
|
||||
|
||||
- [`dynamic-inventory`](dynamic-inventory/): Two example dynamic inventory scripts (one in PHP, one in Python) for use with Ansible.
|
||||
|
||||
### Chapter 9
|
||||
|
||||
- [`lamp-infrastructure`](lamp-infrastructure/): A multi-server LAMP-based web application infrastructure focused on high-availability and performance for a LAMP-stack app.
|
||||
- [`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.
|
||||
|
||||
### Chapter 9
|
||||
### Chapter 10
|
||||
|
||||
- [`deployments`](deployments/): A playbook that deploys a Ruby on Rails application into an environment that runs Passenger and Nginx to handle web requests.
|
||||
- [`deployments-balancer`](deployments-balancer/): A playbook that handles zero-downtime deployments to webservers running behind an HAProxy load balancer.
|
||||
- [`deployments-rolling`](deployments-rolling/): A playbook that demonstrates rolling deployments to multiple servers for a Node.js app.
|
||||
|
||||
### Chapter 10
|
||||
### Chapter 11
|
||||
|
||||
- N/A
|
||||
|
||||
### Chapter 11
|
||||
### Chapter 12
|
||||
|
||||
- [`jenkins`](jenkins/): A playbook that installs and configures Jenkins for CI/CD.
|
||||
|
||||
### Chapter 12
|
||||
### Chapter 13
|
||||
|
||||
- [`molecule`](molecule/): A Molecule example used for testing and developing an Ansible playbook, or for testing in a Continuous Integration (CI) environment.
|
||||
- [`ci.yml` GitHub Actions workflow](.github/workflows/ci.yml): A GitHub Actions workflow which runs the `molecule` example in a CI environment.
|
||||
|
||||
### Chapter 13
|
||||
### Chapter 14
|
||||
|
||||
- [`https-self-signed`](https-self-signed/): A playbook that generates self-signed certificates.
|
||||
- [`https-letsencrypt`](https-letsencrypt/): A playbook that demonstrates automated certificate management with Let's Encrypt and Ansible.
|
||||
- [`https-nginx-proxy`](https-nginx-proxy/): A playbook that demonstrates proxying HTTPS traffic through Nginx to HTTP backends.
|
||||
|
||||
### Chapter 14
|
||||
### Chapter 15
|
||||
|
||||
- [`docker`](docker/): Very simple playbook demonstrating Ansible's ability to manage Docker container images.
|
||||
- [`docker-hubot`](docker-hubot/): Slightly more involved example of Ansible's ability to manage and run Docker container images.
|
||||
|
||||
### Chapter 15
|
||||
### Chapter 16
|
||||
|
||||
- [`kubernetes`](kubernetes/): A playbook that builds a three-node Kubernetes cluster.
|
||||
|
||||
|
10
test-plugin/main.yml
Normal file
10
test-plugin/main.yml
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
- hosts: all
|
||||
|
||||
vars:
|
||||
my_color_choice: blue
|
||||
|
||||
tasks:
|
||||
- name: "Verify {{ my_color_choice }} is a form of blue."
|
||||
assert:
|
||||
that: my_color_choice is blue
|
14
test-plugin/test_plugins/blue.py
Normal file
14
test-plugin/test_plugins/blue.py
Normal file
@ -0,0 +1,14 @@
|
||||
# blue Ansible test plugin definition.
|
||||
|
||||
def is_blue(string):
|
||||
blue_values = ['blue', '#0000ff', '#00f', 'rgb(0,0,255)']
|
||||
if string in blue_values:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
class TestModule(object):
|
||||
''' custom playbook jinja2 tests '''
|
||||
|
||||
def tests(self):
|
||||
return dict(blue=is_blue)
|
2
tests/test-plugin.yml
Normal file
2
tests/test-plugin.yml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
- import_playbook: ../test-plugin/main.yml
|
Reference in New Issue
Block a user