diff --git a/Makefile b/Makefile index 495c0ad..c445dec 100644 --- a/Makefile +++ b/Makefile @@ -1,111 +1,119 @@ # vim: set noexpandtab: ANSIBLE = ansible-playbook SKIP_TAGS = --skip-tags "init,common" PROD_BOOK = books/main_prod.yml TEST_BOOK = books/main_test.yml +PROD_VARS = ../vars/main.yml +TEST_VARS = ../vars/test.yml status: nova list # Everything list: $(ANSIBLE) $(PROD_BOOK) --list-hosts test-list: $(ANSIBLE) $(TEST_BOOK) --list-hosts init: $(ANSIBLE) $(PROD_BOOK) test-init: $(ANSIBLE) $(TEST_BOOK) up: $(ANSIBLE) $(PROD_BOOK) $(SKIP_TAGS) test-up: $(ANSIBLE) $(TEST_BOOK) $(SKIP_TAGS) restart: $(ANSIBLE) books/restart.yml reboot: $(ANSIBLE) books/reboot.yml stop: $(ANSIBLE) books/stop.yml +version: + $(ANSIBLE) --extra-vars="var=$(PROD_VARS)" books/versions.yml + +test-version: + $(ANSIBLE) --extra-vars="var=$(TEST_VARS)" books/versions.yml + # Specific app: $(ANSIBLE) $(PROD_BOOK) --tags conf-app $(SKIP_TAGS) test-app: $(ANSIBLE) $(TEST_BOOK) --tags conf-app $(SKIP_TAGS) fs: $(ANSIBLE) $(PROD_BOOK) --tags conf-fs $(SKIP_TAGS) test-fs: $(ANSIBLE) $(TEST_BOOK) --tags conf-fs $(SKIP_TAGS) phd: $(ANSIBLE) $(PROD_BOOK) --tags conf-phd $(SKIP_TAGS) test-phd: $(ANSIBLE) $(TEST_BOOK) --tags conf-phd $(SKIP_TAGS) lbs: $(ANSIBLE) $(PROD_BOOK) --tags conf-lbs $(SKIP_TAGS) test-lbs: $(ANSIBLE) $(TEST_BOOK) --tags conf-lbs $(SKIP_TAGS) monit: $(ANSIBLE) $(PROD_BOOK) --tags conf-monit $(SKIP_TAGS) test-monit: $(ANSIBLE) $(TEST_BOOK) --tags conf-monit $(SKIP_TAGS) backup: $(ANSIBLE) $(PROD_BOOK) --tags conf-backup $(SKIP_TAGS) dbs: $(ANSIBLE) $(PROD_BOOK) --tags conf-dbs $(SKIP_TAGS) test-dbs: $(ANSIBLE) $(TEST_BOOK) --tags conf-dbs $(SKIP_TAGS) ci: $(ANSIBLE) $(PROD_BOOK) --tags jenkins $(SKIP_TAGS) ci-slave: $(ANSIBLE) $(PROD_BOOK) --tags conf-ci-slave $(SKIP_TAGS) shib: $(ANSIBLE) $(PROD_BOOK) --tags conf-shib $(SKIP_TAGS) gluster: $(ANSIBLE) $(PROD_BOOK) --tags gluster $(SKIP_TAGS) common: $(ANSIBLE) $(PROD_BOOK) --tags common --skip-tags init # Utils update-phab: $(ANSIBLE) books/update_prod.yml test-update-phab: $(ANSIBLE) books/update_test.yml security: $(ANSIBLE) books/security-update.yml arbitrator: $(ANSIBLE) books/arbitrator.yml clean: $(ANSIBLE) books/cleanup.yml diff --git a/books/main_prod.yml b/books/main_prod.yml index f1e288a..5824bb9 100644 --- a/books/main_prod.yml +++ b/books/main_prod.yml @@ -1,35 +1,38 @@ --- - name: Create Instances hosts: 127.0.0.1 tags: always connection: local gather_facts: false vars_files: - "../vars/main.yml" tasks: - include: ../tasks/create-security-groups.yml tags: [ 'init' ] - include: ../tasks/create-instances.yml tags: [ 'always' ] - include: ../tasks/create-volumes.yml tags: [ 'init' ] + - shell: "git show-ref -s --head HEAD | head -n 1" + register: commit + tags: [ 'always' ] - include: main_servers.yml var=../vars/main.yml - name: Configure Backup server hosts: backup tags: conf-backup vars_files: - "../vars/main.yml" vars: nagios_nrpe_server_allowed_hosts: "86.119.30.4,127.0.0.1" user: centos sudo: yes roles: - role: ../roles/common tags: [ 'common' ] - role: ../roles/swap/roles/swap tags: [ 'common' ] - role: ../roles/nrpe tags: [ 'common', 'conf-monit' ] - role: ../roles/backup diff --git a/books/main_servers.yml b/books/main_servers.yml index 18856a9..dd184ac 100644 --- a/books/main_servers.yml +++ b/books/main_servers.yml @@ -1,240 +1,254 @@ --- - name: Configure Jump Server hosts: lbs tags: conf-lbs vars_files: - "{{ var }}" vars: nagios_nrpe_server_allowed_hosts: "{{ groups['monit'][0] }},127.0.0.1" user: centos sudo: yes roles: - role: ../roles/common tags: [ 'common' ] - role: ../roles/swap/roles/swap tags: [ 'common' ] - role: ../roles/ganglia-gmond tags: [ 'common' ] - role: ../roles/nrpe tags: [ 'common', 'conf-monit' ] - role: ../roles/postfix postfix_mynetworks: [ "{{ ip_range }}" ] enable_postfix_relayhost: false - role: ../roles/letsencrypt when: env != "test" - role: ../roles/haproxy - role: ../roles/jump + tasks: + - shell: "echo {{ hostvars['127.0.0.1']['commit']['stdout'] }} > /{{ project_name }}_version" handlers: - include: ../handlers/main.yml #- name: Configure keepalived for jump # hosts: c4science-jump00 # roles: # - role: ../rolesepalived # keepalived_shared_ip: "{{ external_ip }}" # keepalived_role: ../rolesaster" #- name: Configure keepalived for jump2 # hosts: c4science-jump01 # roles: # - role: ../rolesepalived # keepalived_shared_ip: "{{ external_ip }}" # keepalived_role: ../roleslave" +# tasks: +# - shell: "echo {{ hostvars['127.0.0.1']['commit']['stdout'] }} > /{{ project_name }}_version" - name: Configure Monitoring Server hosts: monit tags: conf-monit vars_files: - "{{ var }}" vars: nagios_nrpe_server_allowed_hosts: "{{ groups['monit'][0] }},127.0.0.1" user: centos sudo: yes roles: - role: ../roles/common tags: [ 'common' ] - role: ../roles/swap/roles/swap tags: [ 'common' ] - role: ../roles/nrpe tags: [ 'common', 'conf-monit' ] - role: ../roles/postfix postfix_relayhost: "[{{ hostvars['127.0.0.1']['openstackjump'].results[0]['openstack']['private_v4'] }}]" tags: [ 'common' ] - role: ../roles/logcheck - role: ../roles/rsyslog - { role: ../roles/apache, apache_config: placeholder.conf } - role: ../roles/nagios - role: ../roles/ganglia-gmond tags: [ 'common' ] - role: ../roles/ganglia-gmetad tasks: - include: ../roles/galera/tasks/install.yml yum_repo: ../roles/galera/files/yum.repo - service: name=mysql enabled=false state=stopped + - shell: "echo {{ hostvars['127.0.0.1']['commit']['stdout'] }} > /{{ project_name }}_version" handlers: - include: ../handlers/main.yml - name: Configure Databases hosts: dbs tags: conf-dbs vars_files: - "{{ var }}" vars: nagios_nrpe_server_allowed_hosts: "{{ groups['monit'][0] }},127.0.0.1" user: centos sudo: yes roles: - role: ../roles/common tags: [ 'common' ] - role: ../roles/swap/roles/swap tags: [ 'common' ] - role: ../roles/nrpe tags: [ 'common', 'conf-monit' ] - role: ../roles/postfix postfix_relayhost: "[{{ hostvars['127.0.0.1']['openstackjump'].results[0]['openstack']['private_v4'] }}]" tags: [ 'common' ] - role: ../roles/ganglia-gmond tags: [ 'common' ] - role: ../roles/galera + tasks: + - shell: "echo {{ hostvars['127.0.0.1']['commit']['stdout'] }} > /{{ project_name }}_version" handlers: - include: ../handlers/main.yml - name: Configure App hosts: app tags: conf-app vars_files: - "{{ var }}" vars: nagios_nrpe_server_allowed_hosts: "{{ groups['monit'][0] }},127.0.0.1" user: centos sudo: yes roles: - role: ../roles/common tags: [ 'common' ] - role: ../roles/swap/roles/swap tags: [ 'common' ] - role: ../roles/nrpe tags: [ 'common', 'conf-monit' ] - role: ../roles/postfix postfix_relayhost: "[{{ hostvars['127.0.0.1']['openstackjump'].results[0]['openstack']['private_v4'] }}]" tags: [ 'common' ] - role: ../roles/ganglia-gmond tags: [ 'common' ] - { role: ../roles/apache, apache_config: phabricator.conf } - role: ../roles/glusterfs tags: ['gluster'] - role: ../roles/phabricator - role: ../roles/shibboleth + tasks: + - shell: "echo {{ hostvars['127.0.0.1']['commit']['stdout'] }} > /{{ project_name }}_version" handlers: - include: ../handlers/main.yml - name: Configure Filesystem for repositories hosts: fs tags: conf-fs vars_files: - "{{ var }}" vars: nagios_nrpe_server_allowed_hosts: "{{ groups['monit'][0] }},127.0.0.1" user: centos sudo: yes roles: - role: ../roles/common tags: [ 'common' ] - role: ../roles/swap/roles/swap tags: [ 'common' ] - role: ../roles/nrpe tags: [ 'common', 'conf-monit' ] - role: ../roles/postfix postfix_relayhost: "[{{ hostvars['127.0.0.1']['openstackjump'].results[0]['openstack']['private_v4'] }}]" tags: [ 'common' ] - role: ../roles/ganglia-gmond tags: [ 'common' ] - role: ../roles/glusterfs tags: ['gluster'] - role: ../roles/fs tags: ['gluster'] + tasks: + - shell: "echo {{ hostvars['127.0.0.1']['commit']['stdout'] }} > /{{ project_name }}_version" handlers: - include: ../handlers/main.yml - name: Configure App Daemons hosts: phd tags: conf-phd vars_files: - "{{ var }}" vars: nagios_nrpe_server_allowed_hosts: "{{ groups['monit'][0] }},127.0.0.1" user: centos sudo: yes roles: - role: ../roles/common tags: [ 'common' ] - role: ../roles/swap/roles/swap tags: [ 'common' ] - role: ../roles/nrpe tags: [ 'common', 'conf-monit' ] - role: ../roles/postfix postfix_relayhost: "[{{ hostvars['127.0.0.1']['openstackjump'].results[0]['openstack']['private_v4'] }}]" tags: [ 'common' ] - role: ../roles/ganglia-gmond tags: [ 'common' ] - role: ../roles/glusterfs tags: ['gluster'] tasks: - include: ../roles/phabricator/tasks/packages.yml - include: ../roles/phabricator/tasks/users.yml - include: ../roles/phabricator/tasks/glusterfs.yml - include: ../roles/phabricator/tasks/install.yml myconfig=../roles/phabricator/templates/myconfig.conf.php - include: ../roles/phabricator/tasks/daemons.yml phd_init: ../roles/phabricator/templates/phd_init + - shell: "echo {{ hostvars['127.0.0.1']['commit']['stdout'] }} > /{{ project_name }}_version" handlers: - include: ../handlers/main.yml - name: Configure Jenkins master hosts: ci vars_files: - "{{ var }}" vars: nagios_nrpe_server_allowed_hosts: "{{ groups['monit'][0] }},127.0.0.1" user: centos sudo: yes roles: - role: ../roles/common tags: [ 'common' ] - role: ../roles/swap/roles/swap tags: [ 'common' ] - role: ../roles/nrpe tags: [ 'common', 'conf-monit' ] - role: ../roles/postfix postfix_relayhost: "[{{ hostvars['127.0.0.1']['openstackjump'].results[0]['openstack']['private_v4'] }}]" tags: [ 'common' ] - role: ../roles/ganglia-gmond tags: [ 'common' ] - role: ../roles/jenkins plugins: - 'preSCMbuildstep' - 'git' - 'build-token-root' - 'phabricator-plugin' - 'docker-plugin' - 'build-monitor-plugin' - 'job-restrictions' - 'project-stats-plugin' - 'cluster-stats' - 'embeddable-build-status' prefix: '/build' email: smtp_host: 'localhost' smtp_ssl: 'false' default_email_suffix: "@{{ domain }}" - role: ../roles tags: [ 'jenkins' ] + tasks: + - shell: "echo {{ hostvars['127.0.0.1']['commit']['stdout'] }} > /{{ project_name }}_version" #- name: Configure Jenkins slave # hosts: ci-slave # tags: conf-ci-slave # vars_files: # - "{{ var }}" # user: core # sudo: yes # roles: # - role: ../rolescker diff --git a/books/main_test.yml b/books/main_test.yml index bb9e0be..6919770 100644 --- a/books/main_test.yml +++ b/books/main_test.yml @@ -1,15 +1,18 @@ --- - name: Create test Instances hosts: 127.0.0.1 tags: always connection: local gather_facts: false vars_files: - "../vars/test.yml" tasks: - include: ../tasks/create-security-groups.yml tags: [ 'init' ] - include: ../tasks/create-instances.yml tags: [ 'always' ] + - shell: "git show-ref -s --head HEAD | head -n 1" + register: commit + tags: [ 'always' ] - include: main_servers.yml var=../vars/test.yml diff --git a/books/versions.yml b/books/versions.yml new file mode 100644 index 0000000..9f5d66c --- /dev/null +++ b/books/versions.yml @@ -0,0 +1,23 @@ +--- +- name: Create Instances + hosts: 127.0.0.1 + tags: always + connection: local + gather_facts: false + vars_files: + - "{{ var }}" + tasks: + - include: ../tasks/create-instances.yml + tags: [ 'always' ] + +- name: Get c4science versions + hosts: all + user: centos + sudo: yes + vars_files: + - "{{ var }}" + tasks: + - shell: "cat /{{ project_name }}_version" + register: res + - debug: msg="{{ res.stdout }}" +