diff --git a/README.md b/README.md index 3637db8..8df9407 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,7 @@ Role Name ========= -A brief description of the role goes here. - -Requirements ------------- - -Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. - -Role Variables --------------- - -A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. - -Dependencies ------------- - -A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. - -Example Playbook ----------------- - -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: - - - hosts: servers - roles: - - { role: username.rolename, x: 42 } +A role that installs a Docker Swarm instance of WebODV License ------- @@ -35,4 +11,4 @@ EUPL-1.2 Author Information ------------------ -An optional section for the role authors to include contact information, or a website (HTML is not allowed). +Andrea Dell'Amico, diff --git a/defaults/main.yml b/defaults/main.yml index 95d3c70..6c22a36 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,2 +1,47 @@ --- -# defaults file for ansible-role-template \ No newline at end of file +bluecloud_webodv_compose_dir: '/srv/bluecloud_webodv_stack' +bluecloud_webodv_docker_stack_name: 'bluecloud_webodv' +bluecloud_webodv_docker_network: 'bluecloud_webodv_net' +# IMPORTANT. Set it to True for the server that is going to host the DB +bluecloud_webodv_behind_haproxy: true +bluecloud_webodv_haproxy_public_net: 'haproxy-public' +#bluecloud_webodv_db_pwd: 'set it in a vault file' +bluecloud_webodv_db_name: 'webodv' +bluecloud_webodv_db_user: 'webodv' +bluecloud_webodv_db_volume: 'bluecloud_webodv_db_data' +bluecloud_webodv_db_volume_type: 'nfs4' +bluecloud_webodv_db_volume_o: "" +bluecloud_webodv_db_volume_device: "" +bluecloud_webodv_dbodv_name: 'wsodv' +bluecloud_webodv_dbodv_user: 'wsodv' +bluecloud_webodv_dbodv_volume: 'bluecloud_webodv_dbodb_data' +bluecloud_webodv_dbodv_volume_type: 'nfs4' +bluecloud_webodv_dbodv_volume_o: "" +bluecloud_webodv_dbodv_volume_device: "" +bluecloud_webodv_data_volume: 'bluecloud_webodv_data' +bluecloud_webodv_data_volume_type: 'nfs4' +bluecloud_webodv_data_volume_o: "" +bluecloud_webodv_data_volume_device: "" + +# Set to 1 when behind a reverse proxy +bluecloud_webodv_reverse_proxy: 0 +# Use https when, you know +bluecloud_webodv_scheme: http +# Public endpoint. Mandatory when https +bluecloud_webodv_root_url: "" +# Secure cookie. True when https +bluecloud_webodv_session_secure_cookie: false +# Set to "none" when behind a reverse proxy +bluecloud_webodv_same_site: "" +bluecloud_webodv_client_url: "localhost" +# Set to "" when behind a reverse proxy +bluecloud_webodv_http_port: 11112 +# Set to true when https +bluecloud_webodv_ssl_client: false +bluecloud_webodv_settings_name: default +bluecloud_webodv_settings_path: /var/www/html/webodv/storage/app/settings +bluecloud_webodv_path_to_settings: settings_webodv +bluecloud_webodv_ws_proxy: webodv_ProxyPass.txt +bluecloud_webodv_mysql_root_password: "{{ vault_webodv_mysql_root_password }}" +bluecloud_webodv_mysql_password: "{{ vault_webodv_mysql_password }}" +bluecloud_webodv_smtp_password: "{{ vault_webodv_smtp_password }}" diff --git a/meta/main.yml b/meta/main.yml index 81bda14..c9cec16 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,46 +1,23 @@ galaxy_info: - author: your name - description: your description - company: your company (optional) + author: Andrea Dell'Amico + namespace: adellam + description: Role that installs a docker swarm stack of WebODV + role_name: bluecloud_webodv + company: ISTI-CNR + license: EUPL 1.2+ - # If the issue tracker for your role is not on github, uncomment the - # next line and provide a value - issue_tracker_url: https://support.d4science.org/projects/automatic-provisioning/issues + min_ansible_version: "2.9" - license: EUPL-1.2 - - min_ansible_version: 2.8 - - # If this a Container Enabled role, provide the minimum Ansible Container version. - # min_ansible_container_version: - - # Optionally specify the branch Galaxy will use when accessing the GitHub - # repo for this role. During role install, if no tags are available, - # Galaxy will use this branch. During import Galaxy will access files on - # this branch. If Travis integration is configured, only notifications for this - # branch will be accepted. Otherwise, in all cases, the repo's default branch - # (usually master) will be used. - #github_branch: - - # - # Provide a list of supported platforms, and for each platform a list of versions. - # If you don't wish to enumerate all versions for a particular platform, use 'all'. # To view available platforms and versions (or releases), visit: # https://galaxy.ansible.com/api/v1/platforms/ # platforms: - - name: Ubuntu - versions: - - bionic - - galaxy_tags: [] - # List tags for your role here, one per line. A tag is a keyword that describes - # and categorizes the role. Users find roles by searching for tags. Be sure to - # remove the '[]' above, if you add tags to this list. - # - # NOTE: A tag is limited to a single word comprised of alphanumeric characters. - # Maximum 20 tags per role. - -dependencies: [] - # List your role dependencies here, one per line. Be sure to remove the '[]' above, - # if you add dependencies to this list. \ No newline at end of file + - name: Ubuntu + versions: + - bionic + - focal + - jammy + - name: EL + versions: + - "7" + - "8" diff --git a/tasks/main.yml b/tasks/main.yml index 53c6cae..ffd54e2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,2 +1,33 @@ --- -# tasks file for ansible-role-template \ No newline at end of file +- name: Create the compose directory + run_once: true + when: docker_swarm_manager_main_node is defined and docker_swarm_manager_main_node | bool + tags: ['bc_webodv'] + block: + - name: Create the compose directory + ansible.builtin.file: + dest: "{{ bluecloud_webodv_compose_dir }}" + state: directory + owner: root + group: root + mode: "0700" + +- name: Manage the installation of the OpenASFA configuration of the swarm service + when: docker_swarm_manager_main_node is defined and docker_swarm_manager_main_node | bool + tags: ['bc_webodv'] + run_once: true + block: + - name: Install the docker compose file of the WebODV service + ansible.builtin.template: + src: docker-compose-webodv.yml.j2 + dest: "{{ bluecloud_webodv_compose_dir }}/docker-open-asfa-stack.yml" + owner: root + group: root + mode: "0400" + + - name: Start the WebODV stack + community.docker.docker_stack: + name: "{{ bluecloud_webodv_docker_stack_name }}" + state: present + compose: + - "{{ bluecloud_webodv_compose_dir }}/docker-open-asfa-stack.yml" diff --git a/templates/docker-compose-webodv.yml.j2 b/templates/docker-compose-webodv.yml.j2 new file mode 100644 index 0000000..8329bae --- /dev/null +++ b/templates/docker-compose-webodv.yml.j2 @@ -0,0 +1,147 @@ +version: '3.8' + +networks: + {{ bluecloud_webodv_haproxy_public_net }}: + external: true + {{ bluecloud_webodv_docker_network }}: + +volumes: + {{ bluecloud_webodv_db_volume }}: + driver: local + driver_opts: + type: {{ bluecloud_webodv_db_volume_type }} + o: "{{ bluecloud_webodv_db_volume_o }}" + device: "{{ bluecloud_webodv_db_volume_device }}" + {{ bluecloud_webodv_dbodv_volume }}: + driver: local + driver_opts: + type: {{ bluecloud_webodv_dbodv_volume_type }} + o: "{{ bluecloud_webodv_dbodv_volume_o }}" + device: "{{ bluecloud_webodv_dbodv_volume_device }}" + {{ bluecloud_webodv_data_volume }}: + driver: local + driver_opts: + type: {{ bluecloud_webodv_data_volume_type }} + o: "{{ bluecloud_webodv_data_volume_o }}" + device: "{{ bluecloud_webodv_data_volume_device }}" + +services: + db: + image: mysql/mysql-server:8.0.0 + environment: + MYSQL_ROOT_PASSWORD: {{ bluecloud_webodv_mysql_root_password }} + MYSQL_DATABASE: {{ bluecloud_webodv_db_name }} + MYSQL_USER: {{ bluecloud_webodv_db_user }} + MYSQL_PASSWORD: {{ bluecloud_webodv_mysql_password }} + networks: + - {{ bluecloud_webodv_docker_network }} + volumes: + - {{ bluecloud_webodv_db_volume }}:/var/lib/mysql + deploy: + placement: + constraints: [node.role == worker] + restart_policy: + condition: on-failure + delay: 5s + max_attempts: 3 + window: 120s + logging: + driver: 'journald' + dbodv: + image: mysql/mysql-server:8.0.0 + environment: + MYSQL_ROOT_PASSWORD: {{ bluecloud_webodv_mysql_root_password }} + MYSQL_DATABASE: {{ bluecloud_webodv_dbodv_name }} + MYSQL_USER: {{ bluecloud_webodv_dbodv_user }} + MYSQL_PASSWORD: {{ bluecloud_webodv_mysql_password }} + networks: + - {{ bluecloud_webodv_docker_network }} + volumes: + - {{ bluecloud_webodv_dbodv_volume }}:/var/lib/mysql + deploy: + placement: + constraints: [node.role == worker] + restart_policy: + condition: on-failure + delay: 5s + max_attempts: 3 + window: 120s + logging: + driver: 'journald' + phpmyadmin_db: + image: phpmyadmin/phpmyadmin + networks: + - {{ bluecloud_webodv_haproxy_public_net }} + - {{ bluecloud_webodv_docker_network }} + environment: + PMA_HOST: db + PMA_PORT: 3306 + deploy: + placement: + constraints: [node.role == worker] + restart_policy: + condition: on-failure + delay: 5s + max_attempts: 3 + window: 120s + logging: + driver: 'journald' + phpmyadmin_dbodv: + image: phpmyadmin/phpmyadmin + depends_on: + - dbodv + ports: + - 11110:80 + networks: + - {{ bluecloud_webodv_haproxy_public_net }} + - {{ bluecloud_webodv_docker_network }} + environment: + PMA_HOST: dbodv + PMA_PORT: 3306 + deploy: + placement: + constraints: [node.role == worker] + restart_policy: + condition: on-failure + delay: 5s + max_attempts: 3 + window: 120s + logging: + driver: 'journald' + webodv: + image: smieruch/webodv_bluecloud:latest + depends_on: + - dbodv + - db + ports: + - 11112:80 + networks: + - haproxy-public + - {{ bluecloud_webodv_docker_network }} + volumes: + - {{ bluecloud_webodv_data_volume }}:/var/www/html/webodv/storage/app/default:rw + environment: + settings_name: {{ bluecloud_webodv_settings_name }} + settings_path: {{ bluecloud_webodv_settings_path }} + path_to_odv_settings: {{ bluecloud_webodv_path_to_settings }} + proxy_ws: {{ bluecloud_webodv_ws_proxy }} + REVERSE_PROXY: {{ bluecloud_webodv_reverse_proxy }} + FORCE_SCHEME: {{ bluecloud_webodv_scheme }} + FORCE_ROOT_URL: {{ bluecloud_webodv_root_url }} + SESSION_SECURE_COOKIE: {{ bluecloud_webodv_session_secure_cookie }} + SAME_SITE: {{ bluecloud_webodv_same_site }} + MAIL_PASSWORD: {{ bluecloud_webodv_smtp_password }} + DB_PASSWORD: {{ bluecloud_webodv_mysql_password }} + SSH_CLIENT: {{ bluecloud_webodv_ssl_client }} + CLIENT_URL: {{ bluecloud_webodv_client_url }} + HTTP_PORT: {{ bluecloud_webodv_http_port }} + deploy: + placement: + constraints: [node.role == worker] + restart_policy: + condition: on-failure + delay: 5s + max_attempts: 3 + window: 120s + logging: + driver: 'journald' diff --git a/tests/inventory b/tests/inventory deleted file mode 100644 index 878877b..0000000 --- a/tests/inventory +++ /dev/null @@ -1,2 +0,0 @@ -localhost - diff --git a/tests/test.yml b/tests/test.yml deleted file mode 100644 index 4ba2a88..0000000 --- a/tests/test.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- hosts: localhost - remote_user: root - roles: - - ansible-role-template \ No newline at end of file