From ae8283094ad086aa81903f640bd9847354a9db59 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Thu, 14 Jul 2016 12:40:31 +0200 Subject: [PATCH] library/roles/smartgears: Simplify the smartgears template management. Add a conditional to handle the case where no VO is needed, see https://support.d4science.org/issues/4723. --- smartgears/smart_executor/tasks/main.yml | 59 +++++++------------ .../templates/smart_executor-container.xml.j2 | 34 ----------- smartgears/smartgears/defaults/main.yml | 1 + .../smartgears/tasks/smartgears-app.yml | 1 - .../smartgears/templates/container.xml.j2 | 12 +++- 5 files changed, 33 insertions(+), 74 deletions(-) delete mode 100644 smartgears/smart_executor/templates/smart_executor-container.xml.j2 diff --git a/smartgears/smart_executor/tasks/main.yml b/smartgears/smart_executor/tasks/main.yml index de1fe8a..d2d462c 100644 --- a/smartgears/smart_executor/tasks/main.yml +++ b/smartgears/smart_executor/tasks/main.yml @@ -1,41 +1,24 @@ --- -- name: Remove the old smart executor files - file: path={{ smartgears_instance_path }}/webapps/{{ smart_executor_name }} state=absent - when: - - smart_executor_install - - smartgears_upgrade - tags: [ 'smartgears', 'tomcat' ] - -# NOTE: Install as the smartgears user so we do not mess with the permissions -- name: Get the smart executor plugin - get_url: url={{ smart_executor_url }} dest={{ smartgears_user_home }}/{{ smart_executor_file }} - when: smart_executor_install - tags: [ 'smartgears', 'smart_executor', 'tomcat' ] - -- name: Create the smart executor working directory - file: path={{ smartgears_instance_path }}/webapps/{{ smart_executor_name }} state=directory owner={{ smartgears_user }} group={{ smartgears_user }} - when: smart_executor_install - tags: [ 'smartgears', 'smart_executor', 'tomcat' ] - -- name: Unarchive the smartexecutor distribution - become: True - become_user: '{{ smartgears_user }}' - unarchive: copy=no src={{ smartgears_user_home }}/{{ smart_executor_file }} dest={{ smartgears_instance_path }}/webapps/{{ smart_executor_name }} creates={{ smartgears_instance_path }}/webapps/{{ smart_executor_name }}/WEB-INF/lib - when: smart_executor_install - notify: Restart smartgears - tags: [ 'smartgears', 'smart_executor', 'tomcat' ] - -- name: Install the smartgears configuration file - template: src=smart_executor-container.xml.j2 dest={{ smartgears_install_path }}/container.xml owner={{ item.user }} group={{ item.user }} - with_items: '{{ tomcat_m_instances }}' - notify: Restart smartgears - when: smart_executor_install - register: smartexec_containerxml_state - tags: [ 'smartgears', 'smart_executor', 'smart_executor_conf', 'tomcat' ] +- block: -- name: Remove the smartgears application state if the configuration changed - file: dest={{ smartgears_install_path }}/state state=absent - notify: Restart smartgears - when: ( smartexec_containerxml_state | changed ) - tags: [ 'smartgears', 'smart_executor', 'smart_executor_conf', 'tomcat' ] + - name: Remove the old smart executor files + file: path={{ smartgears_instance_path }}/webapps/{{ smart_executor_name }} state=absent + when: + - smart_executor_install + - smartgears_upgrade + # NOTE: Install as the smartgears user so we do not mess with the permissions + - name: Get the smart executor plugin + get_url: url={{ smart_executor_url }} dest={{ smartgears_user_home }}/{{ smart_executor_file }} + when: smart_executor_install + + - name: Create the smart executor working directory + file: path={{ smartgears_instance_path }}/webapps/{{ smart_executor_name }} state=directory owner={{ smartgears_user }} group={{ smartgears_user }} + when: smart_executor_install + + - name: Unarchive the smartexecutor distribution + unarchive: copy=no src={{ smartgears_user_home }}/{{ smart_executor_file }} dest={{ smartgears_instance_path }}/webapps/{{ smart_executor_name }} creates={{ smartgears_instance_path }}/webapps/{{ smart_executor_name }}/WEB-INF/lib + when: smart_executor_install + notify: Restart smartgears + + tags: [ 'smartgears', 'smart_executor', 'tomcat' ] diff --git a/smartgears/smart_executor/templates/smart_executor-container.xml.j2 b/smartgears/smart_executor/templates/smart_executor-container.xml.j2 deleted file mode 100644 index eaec0a2..0000000 --- a/smartgears/smart_executor/templates/smart_executor-container.xml.j2 +++ /dev/null @@ -1,34 +0,0 @@ - - {{ smartgears_hostname }} -{%if setup_nginx %} -{%if https_port is defined %} - {{ https_port }} -{% else %} - {{ http_port }} -{% endif %} -{% else %} - {{ item.http_port }} -{% endif %} - {{ smartgears_infrastructure_name }} - {{ smartgears_vo_name }} - - - {{ smartgears_country }} - {{ smartgears_location }} - 41.9000 - 12.5000 - - - - - 60 - -{% if smart_executor_install %} - -{% for context in smart_executor_contexts_list %} - /{{ smartgears_infrastructure_name }}/{{ smartgears_vo_name }}{{ context }} -{% endfor %} - -{% endif %} - - diff --git a/smartgears/smartgears/defaults/main.yml b/smartgears/smartgears/defaults/main.yml index 27e820c..899005e 100644 --- a/smartgears/smartgears/defaults/main.yml +++ b/smartgears/smartgears/defaults/main.yml @@ -21,6 +21,7 @@ smartgears_url: 'http://maven.research-infrastructures.eu/nexus/content/reposito smartgears_mode: online # Production infra and VO smartgears_infrastructure_name: "d4science.research-infrastructures.eu" +smartgears_vo: True smartgears_vo_name: gCubeApps smartgears_hostname: '{{ ansible_fqdn }}' smartgears_country: it diff --git a/smartgears/smartgears/tasks/smartgears-app.yml b/smartgears/smartgears/tasks/smartgears-app.yml index afe26e1..a3175bf 100644 --- a/smartgears/smartgears/tasks/smartgears-app.yml +++ b/smartgears/smartgears/tasks/smartgears-app.yml @@ -50,7 +50,6 @@ - name: Install the smartgears configuration file template: src=container.xml.j2 dest={{ smartgears_install_path }}/container.xml owner={{ item.user }} group={{ item.user }} with_items: '{{ tomcat_m_instances }}' - when: ( generic_worker_install is not defined ) or ( not generic_worker_install ) register: containerxml_state notify: Restart smartgears tags: [ 'smartgears', 'smartgears_conf', 'tomcat' ] diff --git a/smartgears/smartgears/templates/container.xml.j2 b/smartgears/smartgears/templates/container.xml.j2 index 3649a3e..0f67989 100644 --- a/smartgears/smartgears/templates/container.xml.j2 +++ b/smartgears/smartgears/templates/container.xml.j2 @@ -11,8 +11,10 @@ {{ item.http_port }} {% endif %} {{ smartgears_infrastructure_name }} +{% if smartgears_vo %} {{ smartgears_vo_name }} - +{% endif %} + {{ smartgears_country }} {{ smartgears_location }} @@ -23,5 +25,13 @@ 60 +{% if smart_executor_install is defined and smart_executor_install %} + + +{% for context in smart_executor_contexts_list %} + /{{ smartgears_infrastructure_name }}/{{ smartgears_vo_name }}{{ context }} +{% endfor %} + +{% endif %}