First commit.
This commit is contained in:
parent
07a451c1e4
commit
b787d59a29
27
README.md
27
README.md
|
@ -1,31 +1,22 @@
|
|||
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.
|
||||
A role that installs a MySQL/phpMyAdmin docker swarm stack.
|
||||
|
||||
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.
|
||||
The most important variables are listed below:
|
||||
|
||||
``` yaml
|
||||
users_system_users:
|
||||
- { login: 'foo', name: "Foo Bar", home: '{{ users_home_dir }}', createhome: 'yes', ssh_key: '{{ foo_ssh_key }}', shell: '/bin/bash', admin: False, log_as_root: False }
|
||||
```
|
||||
|
||||
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 }
|
||||
None
|
||||
|
||||
License
|
||||
-------
|
||||
|
@ -35,4 +26,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, <andrea.dellamico@isti.cnr.it>
|
||||
|
|
|
@ -1,2 +1,8 @@
|
|||
---
|
||||
# defaults file for ansible-role-template
|
||||
taf_mysql_compose_dir: '/srv/taf_mysql_stack'
|
||||
taf_mysql_docker_stack_name: 'sofia-taf-mysql'
|
||||
taf_mysql_compose_file: 'sofia-taf-mysql-docker-compose.yml.j2'
|
||||
taf_mysql_network: 'sofia-taf-mysql'
|
||||
# mysql_root_password: 'set it in a vault file'
|
||||
# mysql_password: 'set it in a vault file'
|
||||
pep_url_prefix: "https://code-repo.d4science.org/gCubeSystem/d4s-nginx-pep-examples/raw/branch/master/gcube-token-docker"
|
|
@ -1,46 +1,28 @@
|
|||
galaxy_info:
|
||||
author: your name
|
||||
description: your description
|
||||
company: your company (optional)
|
||||
author: Andrea Dell'Amico
|
||||
description: Systems Architect
|
||||
company: ISTI-CNR
|
||||
|
||||
# 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
|
||||
issue_tracker_url: https://support.d4science.org/projects/d4science-operation
|
||||
|
||||
license: EUPL-1.2
|
||||
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
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- bionic
|
||||
- name: EL
|
||||
versions:
|
||||
- 7
|
||||
|
||||
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.
|
||||
galaxy_tags:
|
||||
- mei-generator
|
||||
- bluecloud
|
||||
|
||||
dependencies: []
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
||||
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
---
|
||||
- name: Get the Docker file and the pep and nginx templates
|
||||
block:
|
||||
- name: Create a temporary directory to store the Docker pieces
|
||||
ansible.builtin.file:
|
||||
dest: '{{ item }}'
|
||||
state: directory
|
||||
mode: 0700
|
||||
loop:
|
||||
- /var/tmp/sofia-taf-mysql-templates
|
||||
- /var/tmp/sofia-taf-mysql
|
||||
|
||||
- name: Download the Docker templates
|
||||
ansible.builtin.get_url:
|
||||
url: '{{ pep_url_prefix }}/{{ item }}.j2'
|
||||
dest: '/var/tmp/sofia-taf-mysql-templates/{{ item }}.j2'
|
||||
loop:
|
||||
- Dockerfile
|
||||
- nginx.default.conf
|
||||
- pep-swarm.yml
|
||||
- pep.js
|
||||
|
||||
- name: Download the files used to build the Docker image
|
||||
ansible.builtin.get_url:
|
||||
url: '{{ pep_url_prefix }}/{{ item }}'
|
||||
dest: '/var/tmp/sofia-taf-mysql/{{ item }}'
|
||||
loop:
|
||||
- nginx.conf
|
||||
|
||||
- name: Transform the downloaded templates
|
||||
ansible.builtin.template:
|
||||
src: '/var/tmp/sofia-taf-mysql-templates/{{ item }}.j2'
|
||||
dest: '/var/tmp/sofia-taf-mysql/{{ item }}'
|
||||
loop:
|
||||
- Dockerfile
|
||||
- nginx.default.conf
|
||||
- pep-swarm.yml
|
||||
- pep.js
|
||||
|
||||
- name: Login into the docker registry
|
||||
shell: docker login -u {{ docker_registry_username }} -p {{ docker_registry_password }} {{ docker_registry_host }}
|
||||
|
||||
- name: Build and push the Docker image
|
||||
ansible.builtin.docker_image:
|
||||
build:
|
||||
path: /var/tmp/sofia-taf-mysql
|
||||
pull: True
|
||||
name: '{{ docker_registry_host }}/{{ docker_target_image }}'
|
||||
tag: latest
|
||||
push: True
|
||||
force_source: True
|
||||
force_tag: True
|
||||
source: build
|
||||
state: present
|
||||
|
||||
become: False
|
||||
remote_user: "{{ lookup('env','USER') }}"
|
||||
delegate_to: localhost
|
||||
tags:
|
||||
- sofia_taf_mysql_pep_image
|
||||
- sofia_taf_msql
|
|
@ -1,2 +1,3 @@
|
|||
---
|
||||
# tasks file for ansible-role-template
|
||||
- include_tasks: build-the-pep-image.yml
|
||||
- include_tasks: sofia-taf-mysql-stack.yml
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
- name: Manage the installation of the SOFIA-TAF mysql project Docker stack
|
||||
block:
|
||||
- name: Create the directory where the compose file will be installed
|
||||
ansible.builtin.file:
|
||||
dest: '{{ taf_mysql_compose_dir }}'
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: Install the docker compose file of the SOFIA-TAF mysql project
|
||||
ansible.builtin.template:
|
||||
src: sofia-taf-mysql-docker-compose.yml.j2
|
||||
dest: '{{ taf_mysql_compose_dir }}/sofia-taf-mysql-docker-compose.yml'
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0400
|
||||
|
||||
- name: Start the SOFIA-TAF mysql stack
|
||||
docker_stack:
|
||||
name: '{{ taf_mysql_docker_stack_name }}'
|
||||
state: present
|
||||
compose:
|
||||
- '{{ taf_mysql_compose_dir }}/sofia-taf-mysql-docker-compose.yml'
|
||||
|
||||
tags:
|
||||
- sofia_taf_mysql_stack
|
||||
- sofia_taf_msql
|
|
@ -0,0 +1,71 @@
|
|||
version: "3.6"
|
||||
|
||||
networks:
|
||||
haproxy-public:
|
||||
external: true
|
||||
{{ taf_mysql_network }}:
|
||||
|
||||
volumes:
|
||||
mysql_db_data:
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: nfs4
|
||||
# o: "nfsvers=4,addr=146.48.123.250,rw,nolock,soft"
|
||||
o: "nfsvers=4,addr=146.48.123.250,rw"
|
||||
device: ":/nfs/sofia_taf_mysql"
|
||||
|
||||
services:
|
||||
sofia-taf-mysql:
|
||||
image: mysql:8-debian
|
||||
networks:
|
||||
- {{ taf_mysql_network }}
|
||||
volumes:
|
||||
- mysql_db_data:/var/lib/mysql
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD={{ mysql_root_password }}
|
||||
- MYSQL_PASSWORD={{ mysql_password }}
|
||||
- MYSQL_USER=sofia-taf-u
|
||||
- MYSQL_DATABASE=sofia-taf
|
||||
deploy:
|
||||
placement:
|
||||
constraints:
|
||||
- node.role == worker
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
window: 120s
|
||||
logging:
|
||||
driver: 'journald'
|
||||
phpmyadmin:
|
||||
image: phpmyadmin
|
||||
networks:
|
||||
- {{ taf_mysql_network }}
|
||||
environment:
|
||||
- PMA_HOST=sofia-taf-mysql
|
||||
deploy:
|
||||
placement:
|
||||
constraints:
|
||||
- node.role == worker
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
window: 120s
|
||||
logging:
|
||||
driver: 'journald'
|
||||
pep:
|
||||
image: {{ docker_registry_host }}/{{ docker_target_image }}
|
||||
networks:
|
||||
- {{ taf_mysql_network }}
|
||||
- haproxy-public
|
||||
deploy:
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints: [node.role == worker]
|
||||
endpoint_mode: dnsrr
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 10s
|
||||
window: 120s
|
||||
|
Loading…
Reference in New Issue