Add role role_deploy_SemanticScuttle.
This commit is contained in:
parent
acb0a5a299
commit
46de9331a5
@ -116,6 +116,13 @@
|
||||
tags: deploy_coturn
|
||||
tags: deploy_coturn
|
||||
|
||||
- name: Include role_deploy_SemanticScuttle
|
||||
ansible.builtin.include_role:
|
||||
name: role_deploy_SemanticScuttle
|
||||
apply:
|
||||
tags: deploy_SemanticScuttle
|
||||
tags: deploy_SemanticScuttle
|
||||
|
||||
- name: delete OVH instance
|
||||
hosts: localhost
|
||||
connection: local
|
||||
|
38
roles/role_deploy_SemanticScuttle/README.md
Normal file
38
roles/role_deploy_SemanticScuttle/README.md
Normal file
@ -0,0 +1,38 @@
|
||||
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 }
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
BSD
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
2
roles/role_deploy_SemanticScuttle/defaults/main.yml
Normal file
2
roles/role_deploy_SemanticScuttle/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
# defaults file for role_deploy_SemanticScuttle
|
2
roles/role_deploy_SemanticScuttle/handlers/main.yml
Normal file
2
roles/role_deploy_SemanticScuttle/handlers/main.yml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
# handlers file for role_deploy_SemanticScuttle
|
52
roles/role_deploy_SemanticScuttle/meta/main.yml
Normal file
52
roles/role_deploy_SemanticScuttle/meta/main.yml
Normal file
@ -0,0 +1,52 @@
|
||||
galaxy_info:
|
||||
author: your name
|
||||
description: your role description
|
||||
company: your company (optional)
|
||||
|
||||
# If the issue tracker for your role is not on github, uncomment the
|
||||
# next line and provide a value
|
||||
# issue_tracker_url: http://example.com/issue/tracker
|
||||
|
||||
# Choose a valid license ID from https://spdx.org - some suggested licenses:
|
||||
# - BSD-3-Clause (default)
|
||||
# - MIT
|
||||
# - GPL-2.0-or-later
|
||||
# - GPL-3.0-only
|
||||
# - Apache-2.0
|
||||
# - CC-BY-4.0
|
||||
license: license (GPL-2.0-or-later, MIT, etc)
|
||||
|
||||
min_ansible_version: 2.1
|
||||
|
||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||
# min_ansible_container_version:
|
||||
|
||||
#
|
||||
# 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: Fedora
|
||||
# versions:
|
||||
# - all
|
||||
# - 25
|
||||
# - name: SomePlatform
|
||||
# versions:
|
||||
# - all
|
||||
# - 1.0
|
||||
# - 7
|
||||
# - 99.99
|
||||
|
||||
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.
|
25
roles/role_deploy_SemanticScuttle/tasks/build_image.yml
Normal file
25
roles/role_deploy_SemanticScuttle/tasks/build_image.yml
Normal file
@ -0,0 +1,25 @@
|
||||
---
|
||||
- name: Get {{ item.repo_name }} repo's last commit
|
||||
ansible.builtin.git:
|
||||
repo: "{{ item.repo_url }}"
|
||||
clone: no
|
||||
update: no
|
||||
version: master
|
||||
register: git
|
||||
changed_when: false
|
||||
|
||||
- name: Set fact commit
|
||||
set_fact:
|
||||
commit: "{{ git.after[0:10] }}"
|
||||
|
||||
- name: Build {{ item.image_name }} image
|
||||
containers.podman.podman_image:
|
||||
name: "{{ item.image_name }}"
|
||||
path: "{{ item.repo_url }}"
|
||||
force: true
|
||||
build:
|
||||
force_rm: true
|
||||
annotation:
|
||||
git_commit: "{{ commit }}"
|
||||
become: true
|
||||
register: "{{ item.result_var }}"
|
136
roles/role_deploy_SemanticScuttle/tasks/main.yml
Normal file
136
roles/role_deploy_SemanticScuttle/tasks/main.yml
Normal file
@ -0,0 +1,136 @@
|
||||
---
|
||||
- name: Check if install from backup is already done
|
||||
stat:
|
||||
path: /mnt/volumes/install_states/scuttle_installed
|
||||
register: scuttle_installed_flag
|
||||
|
||||
- name: Create php5-fpm network
|
||||
containers.podman.podman_network:
|
||||
name: php5-fpm
|
||||
become: true
|
||||
when: not scuttle_installed_flag.stat.exists
|
||||
|
||||
- name: Create volumes directories
|
||||
ansible.builtin.file:
|
||||
path: "/mnt/volumes/{{ item }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
become: true
|
||||
with_items:
|
||||
- scuttle_code
|
||||
- scuttle_php5-fpm_conf
|
||||
when: not scuttle_installed_flag.stat.exists
|
||||
|
||||
- name: Create volumes data directories
|
||||
ansible.builtin.file:
|
||||
path: "/mnt/volumes/{{ item.name }}/data"
|
||||
state: directory
|
||||
owner: "{{ item.user }}"
|
||||
group: "{{ item.user }}"
|
||||
mode: '0755'
|
||||
become: true
|
||||
with_items:
|
||||
- name: scuttle_code
|
||||
user: 33
|
||||
- name: scuttle_php5-fpm_conf
|
||||
user: root
|
||||
when: not scuttle_installed_flag.stat.exists
|
||||
|
||||
- name: change ownership of duplicity working directories
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
owner: "{{ LINUX_USERNAME }}"
|
||||
group: "{{ LINUX_USERNAME }}"
|
||||
become: true
|
||||
with_items:
|
||||
- "{{ DUPLICITY_WORKDIR }}"
|
||||
- "{{ DUPLICITY_ARCHIVE_DIR }}"
|
||||
when: not scuttle_installed_flag.stat.exists
|
||||
|
||||
- name: restore volume backup
|
||||
ansible.builtin.command:
|
||||
cmd: "duplicity restore --file-to-restore {{ item }}.tar.gz --do-not-restore-ownership --archive-dir {{ DUPLICITY_ARCHIVE_DIR }} swift://backup_ovh1 {{ DUPLICITY_WORKDIR }}/{{ item }}.tar.gz"
|
||||
environment:
|
||||
SWIFT_USERNAME: "{{ OS_USERNAME }}"
|
||||
SWIFT_PASSWORD: "{{ OS_PASSWORD }}"
|
||||
SWIFT_AUTHURL: "{{ OS_AUTH_URL }}"
|
||||
SWIFT_REGIONNAME: "{{ SWIFT_REGIONNAME }}"
|
||||
SWIFT_TENANTNAME: "{{ OS_TENANT_NAME }}"
|
||||
SWIFT_AUTHVERSION: "{{ OS_IDENTITY_API_VERSION }}"
|
||||
PASSPHRASE: "{{ DUPLICITY_PASSPHRASE}}"
|
||||
# /usr/bin/duplicity uses "-s" python argument to prevent loading modules from user's python directory,
|
||||
# this variable will override that.
|
||||
PYTHONPATH: ".local/lib/python3.9/site-packages"
|
||||
register: duplicity_result
|
||||
with_items:
|
||||
- scuttle_code
|
||||
- scuttle_php5-fpm_conf
|
||||
failed_when: duplicity_result is failed and (duplicity_result.rc is not defined or duplicity_result.rc != 11)
|
||||
changed_when: duplicity_result.rc is defined and duplicity_result.rc == 0
|
||||
when: not scuttle_installed_flag.stat.exists
|
||||
|
||||
- name: Unarchive volume backup
|
||||
ansible.builtin.command:
|
||||
cmd: "tar -xzvf {{ DUPLICITY_WORKDIR }}/{{ item }}.tar.gz -C /mnt/volumes/{{ item }}/data --strip 2"
|
||||
become: true
|
||||
with_items:
|
||||
- scuttle_code
|
||||
- scuttle_php5-fpm_conf
|
||||
when: not scuttle_installed_flag.stat.exists
|
||||
|
||||
# A local volume is needed to store install states
|
||||
- name: Create /mnt/volumes/install_states directory if it does not exist
|
||||
ansible.builtin.file:
|
||||
path: "/mnt/volumes/install_states"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
become: true
|
||||
when: not scuttle_installed_flag.stat.exists
|
||||
|
||||
- name: Create scuttle_installed state file
|
||||
ansible.builtin.file:
|
||||
path: "/mnt/volumes/install_states/scuttle_installed"
|
||||
state: touch
|
||||
mode: '0755'
|
||||
become: true
|
||||
when: not scuttle_installed_flag.stat.exists
|
||||
|
||||
- name: Include build_image.yml
|
||||
ansible.builtin.include_tasks: "tasks/build_image.yml"
|
||||
with_items:
|
||||
- repo_url: "https://git.{{ DOMAIN }}/yohan/docker-apache-for-fpm.git"
|
||||
repo_name: docker-apache-for-fpm
|
||||
image_name: apache-scuttle
|
||||
result_var: apache_scuttle_result
|
||||
- repo_url: "https://git.{{ DOMAIN }}/yohan/docker-php5-fpm.git"
|
||||
repo_name: docker-php5-fpm
|
||||
image_name: php5-fpm
|
||||
result_var: php5_fpm_result
|
||||
|
||||
- name: Create apache-scuttle container
|
||||
containers.podman.podman_container:
|
||||
name: apache-scuttle
|
||||
image: apache-scuttle
|
||||
recreate: "{{ apache_scuttle_result is changed }}"
|
||||
network:
|
||||
- reverse-proxy
|
||||
- php5-fpm
|
||||
volume:
|
||||
- /mnt/volumes/scuttle_code/data:/var/www/html:z
|
||||
env:
|
||||
FPM_HOST: php5-fpm:9000
|
||||
SERVER_NAME: "scuttle.{{ DOMAIN }}"
|
||||
become: true
|
||||
|
||||
- name: Create php5-fpm container
|
||||
containers.podman.podman_container:
|
||||
name: php5-fpm
|
||||
image: php5-fpm
|
||||
recreate: "{{ php5_fpm_result is changed }}"
|
||||
network:
|
||||
- php5-fpm
|
||||
- mysqlnet
|
||||
volume:
|
||||
- /mnt/volumes/scuttle_code/data:/var/www/html:z
|
||||
- /mnt/volumes/scuttle_php5-fpm_conf/data:/etc/php5/fpm/pool.d:Z
|
||||
become: true
|
2
roles/role_deploy_SemanticScuttle/tests/inventory
Normal file
2
roles/role_deploy_SemanticScuttle/tests/inventory
Normal file
@ -0,0 +1,2 @@
|
||||
localhost
|
||||
|
5
roles/role_deploy_SemanticScuttle/tests/test.yml
Normal file
5
roles/role_deploy_SemanticScuttle/tests/test.yml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- role_deploy_SemanticScuttle
|
2
roles/role_deploy_SemanticScuttle/vars/main.yml
Normal file
2
roles/role_deploy_SemanticScuttle/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
# vars file for role_deploy_SemanticScuttle
|
Loading…
Reference in New Issue
Block a user