diff --git a/gcube/authorization_service/defaults/main.yml b/gcube/authorization_service/defaults/main.yml new file mode 100644 index 00000000..e098f0dd --- /dev/null +++ b/gcube/authorization_service/defaults/main.yml @@ -0,0 +1,10 @@ +--- +authorization_service_install: False +authorization_service_name: authorization-service +authorization_service_file: '{{ authorization_service_name }}-2.0.0-20160927.120833-1.war' +authorization_service_url: 'http://maven.research-infrastructures.eu/nexus/content/repositories/gcube-snapshots/org/gcube/common/authorization-service/2.0.0-SNAPSHOT/{{ authorization_service_file }}' +authorization_service_persistence_dest: WEB-INF/classes/META-INF/persistence.xml +authorization_service_config_dest: WEB-INF/AuthorizationConfiguration.xml +authorized_ips: + - 127.0.0.1 + diff --git a/gcube/authorization_service/tasks/main.yml b/gcube/authorization_service/tasks/main.yml new file mode 100644 index 00000000..47c350ed --- /dev/null +++ b/gcube/authorization_service/tasks/main.yml @@ -0,0 +1,31 @@ +--- +- block: + - name: Remove the installed authorization service before upgrading + file: dest={{ item }} state=absent + with_items: + - '{{ auth_instance_path }}/webapps/authorization-service' + - '{{ auth_instance_path }}/webapps/authorization-service.war' + when: authorization_upgrade or not authorization_service_install + + - name: Get the authorization service war file + get_url: url={{ authorization_service_url }} dest={{ auth_instance_path }}/webapps/{{ authorization_service_file }} + + - name: Unpack the authorization service war file + shell: mkdir {{ auth_instance_path }}/webapps/authorization-service ; cd {{ auth_instance_path }}/webapps/authorization-service ; jar xf {{ auth_instance_path }}/webapps/{{ authorization_service_file }} + args: + creates: '{{ auth_instance_path }}/webapps/authorization-service/WEB-INF/AuthorizationConfiguration.xml' + + - name: Install the authorization service AuthorizationConfiguration.xml template + template: src=AuthorizationConfiguration.xml.j2 dest={{ auth_instance_path }}/webapps/authorization-service/{{ authorization_service_config_dest }} mode=0440 + with_items: '{{ tomcat_m_instances }}' + notify: tomcat instances restart + + - name: Install the authorization service persistence.xml template + template: src=persistence.xml.j2 dest={{ auth_instance_path }}/webapps/authorization-service/{{ authorization_service_persistence_dest }} mode=0440 + with_items: '{{ tomcat_m_instances }}' + notify: tomcat instances restart + + become: True + become_user: '{{ auth_user }}' + when: authorization_service_install + tags: ['authorization_service', 'tomcat' ] diff --git a/gcube/authorization_service/templates/AuthorizationConfiguration.xml.j2 b/gcube/authorization_service/templates/AuthorizationConfiguration.xml.j2 new file mode 100644 index 00000000..783c1f1d --- /dev/null +++ b/gcube/authorization_service/templates/AuthorizationConfiguration.xml.j2 @@ -0,0 +1,12 @@ + + + + {% for ip in authorized_ips %} + + {% endfor %} + + + + + + diff --git a/gcube/authorization_service/templates/persistence.xml.j2 b/gcube/authorization_service/templates/persistence.xml.j2 new file mode 100644 index 00000000..3ad39bc0 --- /dev/null +++ b/gcube/authorization_service/templates/persistence.xml.j2 @@ -0,0 +1,33 @@ + + + + + org.eclipse.persistence.jpa.PersistenceProvider + + + org.gcube.common.authorizationservice.persistence.entities.converters.StringListConverter + + + + org.gcube.common.authorizationservice.persistence.entities.AuthorizationEntity + org.gcube.common.authorizationservice.persistence.entities.ServiceAuthorizationEntity + org.gcube.common.authorizationservice.persistence.entities.UserAuthorizationEntity + org.gcube.common.authorizationservice.persistence.entities.ExternalServiceAuthorizationEntity + org.gcube.common.authorizationservice.persistence.entities.NodeAuthorizationEntity + org.gcube.common.authorizationservice.persistence.entities.PolicyEntity + org.gcube.common.authorizationservice.persistence.entities.ServicePolicyEntity + org.gcube.common.authorizationservice.persistence.entities.UserPolicyEntity + + + + + + + + + +