From 0a25209c255218b48cb235632ff5e851045a91d3 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Wed, 20 Jul 2016 13:20:37 +0200 Subject: [PATCH] library/roles/smartgears/install-gcube-key: Now we delete the unwanted keys. --- smartgears/install-gcube-key/tasks/main.yml | 73 +++++++++++++------ .../smartgears/tasks/smartgears-app.yml | 14 ++-- 2 files changed, 59 insertions(+), 28 deletions(-) diff --git a/smartgears/install-gcube-key/tasks/main.yml b/smartgears/install-gcube-key/tasks/main.yml index 87a109f1..a20af7f6 100644 --- a/smartgears/install-gcube-key/tasks/main.yml +++ b/smartgears/install-gcube-key/tasks/main.yml @@ -1,26 +1,55 @@ --- -- name: Install the production gcube keys - get_url: url={{ item.url }} dest=/{{ gcube_tomcat_lib_dir }}/{{ item.name }} owner={{ d4science_user }} group={{ d4science_user }} mode=0400 - with_items: - - '{{ gcube_prod_key_1 }}' - - '{{ gcube_prod_key_2 }}' - - '{{ gcube_prod_key_3 }}' - when: install_gcube_prod_key - tags: gcube_key +- block: + - name: Install the production gcube keys + get_url: url={{ item.url }} dest=/{{ gcube_tomcat_lib_dir }}/{{ item.name }} owner={{ smartgears_user }} group={{ d4science_user }} mode=0400 + with_items: + - '{{ gcube_prod_key_1 }}' + - '{{ gcube_prod_key_2 }}' + - '{{ gcube_prod_key_3 }}' + notify: Restart smartgears + when: install_gcube_prod_key -- name: Install the devel gcube keys - get_url: url={{ item.url }} dest=/{{ gcube_tomcat_lib_dir }}/{{ item.name }} owner={{ d4science_user }} group={{ d4science_user }} mode=0400 - with_items: - - '{{ gcube_dev_key_1 }}' - - '{{ gcube_dev_key_2 }}' - - '{{ gcube_dev_key_3 }}' - when: install_gcube_dev_key - tags: gcube_key + - name: Remove the production gcube keys + file: dest=/{{ gcube_tomcat_lib_dir }}/{{ item.name }} state=absent + with_items: + - '{{ gcube_prod_key_1 }}' + - '{{ gcube_prod_key_2 }}' + - '{{ gcube_prod_key_3 }}' + notify: Restart smartgears + when: not install_gcube_prod_key -- name: Install the preprod gcube keys - get_url: url={{ item.url }} dest=/{{ gcube_tomcat_lib_dir }}/{{ item.name }} owner={{ smartgears_user }} group={{ smartgears_user }} mode=0400 - with_items: - - '{{ gcube_pre_key_1 }}' - notify: Restart smartgears - when: install_gcube_preprod_key + - name: Install the devel gcube keys + get_url: url={{ item.url }} dest=/{{ gcube_tomcat_lib_dir }}/{{ item.name }} owner={{ smartgears_user }} group={{ d4science_user }} mode=0400 + with_items: + - '{{ gcube_dev_key_1 }}' + - '{{ gcube_dev_key_2 }}' + - '{{ gcube_dev_key_3 }}' + notify: Restart smartgears + when: install_gcube_dev_key + + - name: Remove the devel gcube keys + file: dest=/{{ gcube_tomcat_lib_dir }}/{{ item.name }} state=absent + with_items: + - '{{ gcube_dev_key_1 }}' + - '{{ gcube_dev_key_2 }}' + - '{{ gcube_dev_key_3 }}' + notify: Restart smartgears + when: not install_gcube_dev_key + + - name: Install the preprod gcube keys + get_url: url={{ item.url }} dest=/{{ gcube_tomcat_lib_dir }}/{{ item.name }} owner={{ smartgears_user }} group={{ smartgears_user }} mode=0400 + with_items: + - '{{ gcube_pre_key_1 }}' + notify: Restart smartgears + when: install_gcube_preprod_key + + - name: Remove the preprod gcube keys + file: dest=/{{ gcube_tomcat_lib_dir }}/{{ item.name }} state=absent + with_items: + - '{{ gcube_pre_key_1 }}' + notify: Restart smartgears + when: not install_gcube_preprod_key + + become: True + become_user: '{{ smartgears_user }}' tags: gcube_key diff --git a/smartgears/smartgears/tasks/smartgears-app.yml b/smartgears/smartgears/tasks/smartgears-app.yml index a3175bf5..0e62b7a6 100644 --- a/smartgears/smartgears/tasks/smartgears-app.yml +++ b/smartgears/smartgears/tasks/smartgears-app.yml @@ -14,15 +14,15 @@ - name: Unarchive the smartgears distribution become: True - become_user: '{{ d4science_user }}' + become_user: '{{ smartgears_user }}' unarchive: copy=no src={{ smartgears_user_home }}/{{ smartgears_file }} dest={{ smartgears_user_home }} creates={{ smartgears_user_home }}/smartgears-distribution-{{ smartgears_distribution_version }} when: ( new_smartgears_distribution | changed ) tags: [ 'smartgears', 'tomcat' ] - name: Stop the smartgears container before launching the upgrade script become: True - become_user: '{{ d4science_user }}' - shell: /home/{{ d4science_user }}/stopContainer.sh + become_user: '{{ smartgears_user }}' + shell: /home/{{ smartgears_user }}/stopContainer.sh when: smartgears_upgrade tags: [ 'smartgears', 'tomcat', 'stop_smartgears_service' ] @@ -34,7 +34,7 @@ - name: Set the additional tomcat default file as the smartgears user .bashrc become: True - become_user: '{{ d4science_user }}' + become_user: '{{ smartgears_user }}' template: src=tomcat-instance-default.j2 dest={{ item.user_home }}/.bashrc mode=0444 with_items: '{{ tomcat_m_instances }}' tags: [ 'smartgears', 'tomcat', 'smartgears_env' ] @@ -48,7 +48,9 @@ tags: [ 'smartgears', 'tomcat' ] - name: Install the smartgears configuration file - template: src=container.xml.j2 dest={{ smartgears_install_path }}/container.xml owner={{ item.user }} group={{ item.user }} + become: True + become_user: '{{ smartgears_user }}' + template: src=container.xml.j2 dest={{ smartgears_install_path }}/container.xml with_items: '{{ tomcat_m_instances }}' register: containerxml_state notify: Restart smartgears @@ -67,7 +69,7 @@ - name: Change the smartgears log level become: True - become_user: '{{ d4science_user }}' + become_user: '{{ smartgears_user }}' shell: /usr/local/bin/change-logback-loglevel tags: [ 'smartgears', 'tomcat', 'smartgears_loglevel' ]