Skip to content

Commit

Permalink
Clean
Browse files Browse the repository at this point in the history
  • Loading branch information
ahelal committed Dec 7, 2016
1 parent 96403b4 commit 6af3324
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 65 deletions.
14 changes: 14 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ platforms :
concourse-web : [ 'simple-ubuntu1604' ]
concourse-worker : [ 'simple-ubuntu1604', 'worker-ubuntu1604' ]

- name : "centos7"
driver_config :
image : centos:7
platform : centos
provision_command :
- mkdir -p /etc/selinux/targeted/contexts/
- echo '<busconfig><selinux></selinux></busconfig>' > /etc/selinux/targeted/contexts/dbus_contexts
provisioner :
ansible_playbook_bin : "`avm path v2.2`ansible-playbook"
# Hash of other groups
groups :
concourse-web : [ 'simple-centos7' ]
concourse-worker : [ 'simple-centos7' ]

suites:
- name : simple
provisioner :
Expand Down
1 change: 1 addition & 0 deletions tasks/kernel_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
name="linux-generic-lts-vivid"
state=present
register: kernel_update
when: ansible_os_family == 'Debian'

- name: kernel update | Reboot now
command: shutdown -r now
Expand Down
8 changes: 4 additions & 4 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

- name: Common tasks
include: common_nix.yml
when: "{{ ansible_os_family == 'Debian' or ansible_os_family == 'Darwin' }}"
when: "{{ ansible_system == 'Linux' or ansible_system == 'Darwin' }}"

- name: Install tasks
include: install_nix.yml
when: "{{ ansible_os_family == 'Debian' or ansible_os_family == 'Darwin' }}"
when: "{{ ansible_system == 'Linux' or ansible_system == 'Darwin' }}"

- name: Manage web node
include: web_nix.yml
when: "{{ groups[concourseci_web_group] is defined and inventory_hostname in groups[concourseci_web_group] and ansible_os_family == 'Debian' or ansible_os_family == 'Darwin' }}"
when: "{{ groups[concourseci_web_group] is defined and inventory_hostname in groups[concourseci_web_group] and ansible_system == 'Linux' or ansible_system == 'Darwin' }}"

- name: Manage worker node
include: worker_nix.yml
when: "{{ groups[concourseci_worker_group] is defined and inventory_hostname in groups[concourseci_worker_group] and ansible_os_family == 'Debian' or ansible_os_family == 'Darwin' }}"
when: "{{ groups[concourseci_worker_group] is defined and inventory_hostname in groups[concourseci_worker_group] and ansible_system == 'Linux' or ansible_system == 'Darwin' }}"
2 changes: 1 addition & 1 deletion tasks/web_nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
mode=0755
notify:
- restart concourse-web
when: "{{ ansible_os_family == 'Debian' }}"
when: "{{ ansible_system == 'Linux' }}"

- name: web | Ensure Concourse web is running and Starts on boot
service:
Expand Down
2 changes: 1 addition & 1 deletion tasks/worker_nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
mode=0755
notify:
- restart concourse-worker
when: "{{ ansible_os_family == 'Debian' }}"
when: "{{ ansible_system == 'Linux' }}"

- name: Worker | Ensure Concourse worker is running and Starts on boot
service:
Expand Down
51 changes: 51 additions & 0 deletions test/helper_roles/postgresql/tasks/debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---

- name: pre Install demo packages ubuntu
apt:
name="{{item}}"
update_cache=yes
cache_valid_time=3600
with_items:
- "git"
- "postgresql"
- "python-psycopg2"
- "vim"
- "curl"
# this should fail if no match for postgreql path or more than on match
- name: find postgresql path
find:
paths="/etc/postgresql/"
patterns="9.*"
file_type="directory"
register: find_reg
failed_when: find_reg.matched != 1

- name: pre Configure postgresql hba.conf
lineinfile:
dest="{{ find_reg.files[0].path }}/main/pg_hba.conf"
insertafter="EOF"
line="host all all 0.0.0.0/0 md5"
register: postgresql_conf_2

- name: pre Service postgresql
service:
name=postgresql
state=restarted
when: postgresql_conf_1 | changed or postgresql_conf_2 | changed

- name: pre Create postgresql db
postgresql_db:
name=concourse
become_user: postgres

- name: pre Create postgresql user
postgresql_user:
db=concourse
name=concourseci
password=conpass
become_user: postgres

- name: pre Service postgresql
service:
name=postgresql
state=started
60 changes: 4 additions & 56 deletions test/helper_roles/postgresql/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,7 @@
---

- name: pre Install demo packages
apt:
name="{{item}}"
update_cache=yes
cache_valid_time=3600
with_items:
- "git"
- "postgresql"
- "python-psycopg2"
- "vim"
- "curl"
- include: redhat.yml
when: "{{ ansible_os_family == 'RedHat' }}"

# this should fail if no match for postgreql path or more than on match
- name: find postgresql path
find:
paths="/etc/postgresql/"
patterns="9.*"
file_type="directory"
register: find_reg
failed_when: find_reg.matched != 1

- name: pre Configure postgresql
lineinfile:
dest="{{ find_reg.files[0].path }}/main/postgresql.conf"
regexp='^listen_addresses'
line="listen_addresses = '*'"
register: postgresql_conf_1

- name: pre Configure postgresql hba.conf
lineinfile:
dest="{{ find_reg.files[0].path }}/main/pg_hba.conf"
insertafter="EOF"
line="host all all 0.0.0.0/0 md5"
register: postgresql_conf_2

- name: pre Service postgresql
service:
name=postgresql
state=restarted
when: postgresql_conf_1 | changed or postgresql_conf_2 | changed

- name: pre Create postgresql db
postgresql_db:
name=concourse
become_user: postgres

- name: pre Create postgresql user
postgresql_user:
db=concourse
name=concourseci
password=conpass
become_user: postgres

- name: pre Service postgresql
service:
name=postgresql
state=started
- include: debian.yml
when: "{{ ansible_os_family == 'Debian' }}"
46 changes: 46 additions & 0 deletions test/helper_roles/postgresql/tasks/redhat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---

- name: pre Install demo packages centos
yum:
name="{{item}}"
with_items:
- "git"
- "postgresql-server"
- "postgresql-contrib"
- "vim"
- "curl"

- name: init postgresql centos
shell: postgresql-setup initdb
become: True
changed_when: False

- name: pre Configure postgresql hba.conf
lineinfile:
dest="/var/lib/pgsql/data/pg_hba.conf"
insertafter="EOF"
line="host all all 0.0.0.0/0 md5"
register: postgresql_conf_2

- name: pre Service postgresql
service:
name=postgresql
state=restarted
when: postgresql_conf_1 | changed or postgresql_conf_2 | changed

- name: pre Create postgresql db
postgresql_db:
name=concourse
become_user: postgres

- name: pre Create postgresql user
postgresql_user:
db=concourse
name=concourseci
password=conpass
become_user: postgres

- name: pre Service postgresql
service:
name=postgresql
state=started
13 changes: 10 additions & 3 deletions test/integration/simple/simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
changed_when: False

- name: install net-tools
apt:
name=net-tools

- name: Provision my keys
hosts: all
Expand All @@ -28,3 +25,13 @@
- { name: hosts, tags: "hosts" }
- { name: "postgresql", tags: "concourse" }
- { name: "ansible-concourse", tags: "concourse" }

- name: Install packages required for testing
hosts: all
gather_facts: False
become: True
tasks:
- name: install net-tools
apt:
name=net-tools
when: "{{ ansible_os_family == 'Debian' }}"

0 comments on commit 6af3324

Please sign in to comment.