Skip to content

Commit

Permalink
Merge pull request #13 from gahan-corporation/iss11 Closes #11.
Browse files Browse the repository at this point in the history
Passed preflight.
  • Loading branch information
Alexander Laughlin authored Jun 12, 2017
2 parents 84d4bbd + 8fb43ce commit 5f725ed
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 32 deletions.
24 changes: 15 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
---
sudo: required
language: python
services:
- docker
- docker
before_install:
- sudo apt-get -qq update
- sudo apt-get install -o Dpkg::Options::="--force-confold" --force-yes -y docker-engine
install:
- pip install molecule docker
script:
- pip install molecule docker
- docker pull gahancorpcfo/postgres:latest
- docker tag gahancorpcfo/postgres:latest molecule_local/gahancorpcfo/postgres:latest
- cd tests
- ansible-galaxy install git+https://github.com/gahan-corporation/tower.git,v0.1.0 -p .molecule/roles
- molecule converge
- molecule verify
- molecule destroy
- docker pull gahancorpcfo/postgres:latest
- docker tag gahancorpcfo/postgres:latest molecule_local/gahancorpcfo/postgres:latest
- cd tests
- ansible-galaxy install git+https://github.com/gahan-corporation/tower.git,v0.1.0 -p .molecule/roles
- molecule syntax
- molecule converge
#- molecule verify
- molecule destroy
notifications:
webhooks: 'https://galaxy.ansible.com/api/v1/notifications/'
...
Expand Down
16 changes: 8 additions & 8 deletions tasks/check_config_static.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
---
- name: Ensure expected variables are defined
- name: 'Ensure expected variables are defined'
fail: msg="{{ item }} value missing and is required"
when: hostvars[inventory_hostname][item] is not defined
with_items: "{{ check_config_static_required_vars }}"
register: check_config_static_results
tags: check_config_static_vars

- name: Ensure at least one tower host is defined
- name: 'Ensure at least one tower host is defined.'
fail: msg="Must specify at least one host in the tower group {{ groups['tower']|length }}"
when: "groups['tower']|length < 1"
tags: check_config_static_single_primary

- name: Ensure only one database host exists
- name: 'Ensure only one database host exists.'
fail: msg="One, and only one, database host may be specified. Database group hosts {{ groups['database'] }}"
when: "groups['database'] is defined and groups['database']|length > 1"
tags: check_config_static_single_database

- name: Ensure when postgres host is defined that the port is defined
- name: 'Ensure when postgres host is defined that the port is defined.'
fail: msg="pg_host variable defined but pg_port is not defined. Please define it."
when: "pg_host is defined and pg_port is not defined"
register: check_config_static_results
tags: check_config_static_var_pairs

- name: Ensure that when a database host is specified, that pg_host is defined
- name: 'Ensure that when a database host is specified, that pg_host is defined.'
fail: msg="pg_host required when hosts in the database group exist."
when: "groups['database'] is defined and groups['database']|length >= 1 and (pg_host is not defined or pg_host|length < 1)"
tags: check_config_static_database_host

- name: Ensure that when a database host is specified, that pg_port is defined
- name: 'Ensure that when a database host is specified, that pg_port is defined.'
fail: msg="pg_port required when hosts in the database group exist."
when: "groups['database'] is defined and groups['database']|length >= 1 and (pg_port is not defined or pg_port|length < 1)"
tags: check_config_static_database_host

- name: HA mode requires an external postgres database with pg_host defined
- name: 'HA mode requires an external postgres database with pg_host defined.'
fail: msg="pg_host must be defined when multiple hosts exists"
when: "groups['tower'] is defined and groups['tower']|length > 1 and (pg_host is not defined or pg_host|length < 1)"
register: check_config_static_results
tags:
- check_config_static_ha_pg
- check_config_static_ha

- name: HA mode requires an external postgres database with pg_port defined
- name: 'HA mode requires an external postgres database with pg_port defined.'
fail: msg="pg_port must be defined when multiple hosts exists"
when: "groups['tower'] is defined and groups['tower']|length > 1 and (pg_port is not defined or pg_port|length < 1)"
register: check_config_static_results
Expand Down
5 changes: 0 additions & 5 deletions tasks/includes/preflight/defaults/main.yml

This file was deleted.

18 changes: 10 additions & 8 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
user: root
state: present
key: "{{ keys.ssh_public_key }}"
- name: 'Install the missing language pack.'
apt:
name: "{{ item }}"
state: present
update_cache: yes
with_items:
- language-pack-en
- name: "Set some required values for the hosts."
set_fact:
pg_host: 'postgres'
pg_port: '5432'
pg_password: 'notgod'
admin_password: 'alsonotgod'
rabbitmq_password: 'rabbit'
- name: 'Run the check static config.'
include: includes/install.yml
include: ../tasks/check_config_static.yml
- name: "Run the preflight tests."
include: ../tasks/preflight.yml
...
# vim: ft=ansible:
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ docker:
hostname: postgres
port_bindings:
5432: 5433
- name: tower
- name: tower-main
ansible_groups:
- tower
image: gahancorpcfo/ubuntu-xenial-ansible
Expand Down
10 changes: 9 additions & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
---
admin_password: 'alsonotgod'
check_config_static_required_vars:
- pg_host
- pg_port
- pg_password
- admin_password
- rabbitmq_password
min_open_fds: '100'
pg_host: 'postgres'
pg_port: '5432'
pg_password: 'notgod'
admin_password: 'alsonotgod'
rabbitmq_password: 'rabbit'
required_ram: '1000'
...
# vim: ft=ansible:

0 comments on commit 5f725ed

Please sign in to comment.