Update gitlab role + add misc role
This commit is contained in:
parent
d2e59d6bbb
commit
88bbe3a882
@ -1,6 +1,3 @@
|
||||
# Ansible
|
||||
|
||||
Catalogue of Ansible playbooks and helper scripts for server management
|
||||
|
||||
#### Test ansible scripts locally
|
||||
ansible-playbook playbook.yml --connection=local --inventory=127.0.0.1, --limit 127.0.0.1
|
||||
|
6
backup.yml
Normal file
6
backup.yml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
- hosts: all
|
||||
|
||||
roles:
|
||||
- role: gitlab
|
||||
tags: backup
|
@ -1,8 +0,0 @@
|
||||
# Ansible
|
||||
|
||||
Catalogue of Ansible playbooks and helper scripts for server management
|
||||
|
||||
## Gitlab backups
|
||||
|
||||
#### Test ansible scripts locally
|
||||
ansible-playbook playbook.yml --connection=local --inventory=127.0.0.1, --limit 127.0.0.1
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
- hosts: all
|
||||
|
||||
roles:
|
||||
- backup
|
@ -1,29 +0,0 @@
|
||||
---
|
||||
language: python
|
||||
python: "2.7"
|
||||
|
||||
# Use the new container infrastructure
|
||||
sudo: false
|
||||
|
||||
# Install ansible
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- python-pip
|
||||
|
||||
install:
|
||||
# Install ansible
|
||||
- pip install ansible
|
||||
|
||||
# Check ansible version
|
||||
- ansible --version
|
||||
|
||||
# Create ansible.cfg with correct roles_path
|
||||
- printf '[defaults]\nroles_path=../' >ansible.cfg
|
||||
|
||||
script:
|
||||
# Basic role syntax check
|
||||
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
|
||||
|
||||
notifications:
|
||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
@ -1,6 +0,0 @@
|
||||
---
|
||||
# defaults file for gitlab
|
||||
|
||||
gitlab_container_name: gitlab
|
||||
gitlab_backup_directory: # Remote path to the mounted volume containing backups
|
||||
gitlab_local_backup_directory: # Local path to store gitlab backups remotely
|
@ -1,2 +0,0 @@
|
||||
---
|
||||
# handlers file for gitlab
|
@ -1,3 +0,0 @@
|
||||
dependencies: []
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
@ -1,29 +0,0 @@
|
||||
---
|
||||
# tasks file for gitlab
|
||||
- name: Ensure a gitlab container is running.
|
||||
docker_container:
|
||||
name: "{{ gitlab_container_name }}"
|
||||
state: present
|
||||
image: gitlab/gitlab-ce:14.7.0-ce.0
|
||||
comparisons:
|
||||
'*': ignore
|
||||
|
||||
- name: Start gitlab backup
|
||||
community.docker.docker_container_exec:
|
||||
container: "{{ gitlab_container_name }}"
|
||||
command: gitlab-backup create GZIP_RSYNCABLE=yes SKIP=registry
|
||||
|
||||
- name: Get list of backups
|
||||
find:
|
||||
paths: "{{ gitlab_backup_directory }}"
|
||||
register: found_files
|
||||
|
||||
- name: Get latest backup
|
||||
set_fact:
|
||||
latest_file: "{{ found_files.files | sort(attribute='mtime',reverse=true) | first }}"
|
||||
|
||||
- name: Download latest backup from remote
|
||||
ansible.posix.synchronize:
|
||||
src: "{{ latest_file.path }}"
|
||||
dest: "{{ gitlab_local_backup_directory }}"
|
||||
mode: pull
|
@ -1,7 +0,0 @@
|
||||
---
|
||||
|
||||
- name: Backup gitlab
|
||||
include_tasks: gitlab.yml
|
||||
when: inventory_hostname in groups['mainframe']
|
||||
tags:
|
||||
- gitlab
|
@ -1,2 +0,0 @@
|
||||
---
|
||||
# vars file for gitlab
|
@ -1,8 +0,0 @@
|
||||
[mainframe]
|
||||
|
||||
|
||||
[girder_production]
|
||||
|
||||
[all:vars]
|
||||
ansible_ssh_private_key_file=~/.ssh/key
|
||||
ansible_python_interpreter=/usr/bin/python3
|
@ -1,5 +1,6 @@
|
||||
---
|
||||
# defaults file for gitlab
|
||||
gitlab_container_name: gitlab
|
||||
gitlab_backup_directory: . # Remote path to the mounted volume containing backups
|
||||
gitlab_local_backup_directory: # Local path to store gitlab backups remotely
|
||||
gitlab_backup_directory: /opt/services/gitlab
|
||||
gitlab_local_backup_directory: /home/tanguy/backups/
|
||||
gitlab_host: pythagoras-b
|
||||
|
@ -4,7 +4,7 @@
|
||||
docker_container:
|
||||
name: "{{ gitlab_container_name }}"
|
||||
state: present
|
||||
image: gitlab/gitlab-ce:14.7.0-ce.0
|
||||
image: gitlab/gitlab-ce
|
||||
comparisons:
|
||||
'*': ignore
|
||||
|
||||
@ -25,5 +25,5 @@
|
||||
- name: Download latest backup from remote
|
||||
ansible.posix.synchronize:
|
||||
src: "{{ latest_file.path }}"
|
||||
dest: "{{ gitlab_local_backup_directory }}"
|
||||
dest: "{{ gitlab_local_backup_directory }}"/backups
|
||||
mode: pull
|
@ -1,28 +1,7 @@
|
||||
---
|
||||
# tasks file for gitlab
|
||||
- name: Ensure a gitlab container is running.
|
||||
docker_container:
|
||||
name: "{{ gitlab_container_name }}"
|
||||
state: present
|
||||
image: gitlab/gitlab-ce
|
||||
container_default_behavior: no_defaults
|
||||
|
||||
- name: Start gitlab backup
|
||||
community.docker.docker_container_exec:
|
||||
container: "{{ gitlab_container_name }}"
|
||||
command: gitlab-backup create GZIP_RSYNCABLE=yes
|
||||
|
||||
- name: Get list of backups
|
||||
find:
|
||||
paths: "{{ gitlab_backup_directory }}"
|
||||
register: found_files
|
||||
|
||||
- name: Get latest backup
|
||||
set_fact:
|
||||
latest_file: "{{ found_files.files | sort(attribute='mtime',reverse=true) | first }}"
|
||||
|
||||
- name: Download latest backup from remote
|
||||
ansible.posix.synchronize:
|
||||
src: "{{ latest_file.path }}"
|
||||
dest: "{{ gitlab_local_backup_directory }}"
|
||||
delegate_to: delegate.host
|
||||
- name: Init backup procedure
|
||||
include_tasks: backup.yml
|
||||
when: inventory_hostname in groups['{{ gitlab_host }}']
|
||||
tags:
|
||||
- gitlab
|
||||
|
4
misc/defaults/main.yml
Normal file
4
misc/defaults/main.yml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
# defaults file for misc
|
||||
ansible_default_user: autositos
|
||||
ssh_key_filename: id_autositos_rsa
|
2
misc/handlers/main.yml
Normal file
2
misc/handlers/main.yml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
# handlers file for misc
|
52
misc/meta/main.yml
Normal file
52
misc/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.
|
2
misc/tasks/main.yml
Normal file
2
misc/tasks/main.yml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
# tasks file for misc
|
32
misc/tasks/user.yml
Normal file
32
misc/tasks/user.yml
Normal file
@ -0,0 +1,32 @@
|
||||
---
|
||||
- name: Create provisioning user
|
||||
hosts: all
|
||||
become: true
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Create user
|
||||
ansible.builtin.user:
|
||||
name: "{{ ansible_default_user }}"
|
||||
comment: Automation user for ansible
|
||||
state: present
|
||||
append: yes
|
||||
system: True
|
||||
create_home: True
|
||||
|
||||
- name: Generate master SSH key
|
||||
community.crypto.openssh_keypair:
|
||||
path: "/home/{{ ansible_default_user }}/.ssh/{{ ssh_key_filename }}"
|
||||
type: rsa
|
||||
size: 4096
|
||||
state: present
|
||||
force: no
|
||||
tags:
|
||||
- init
|
||||
|
||||
- name: Deploy SSH public key
|
||||
ansible.posix.authorized_key:
|
||||
user: "{{ ansible_default_user }}"
|
||||
state: present
|
||||
key: "{{ lookup('file', '/home/{{ ansible_default_user }}/.ssh/{{ ssh_key_filename }}.pub') }}"
|
||||
when: "'init' not in ansible_run_tags"
|
||||
|
@ -2,4 +2,4 @@
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- gitlab
|
||||
- misc
|
2
misc/vars/main.yml
Normal file
2
misc/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
# vars file for misc
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
|
||||
roles:
|
||||
- gitlab
|
Loading…
Reference in New Issue
Block a user