added the a preparing ansible playbooks for automating new servers
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
---
|
||||
#- synchronize:
|
||||
# mode: pull
|
||||
# #src: "rsync://{{ ansible_host }}{{ docker_root_directory }}/volumes/{{ traefik_backup_volume_name }}/_data/"
|
||||
# src: rsync://{{ ansible_host }}/opt/
|
||||
# dest: "{{ traefik_destination_backup_dir }}"
|
||||
|
||||
- name: Copy a "traefik certificate" file on the remote machine to controller host
|
||||
copy:
|
||||
src: "{{ docker_root_directory }}/volumes/{{ traefik_backup_volume_name }}/_data/"
|
||||
remote_src: yes
|
||||
dest: "{{ traefik_destination_backup_dir }}"
|
||||
directory_mode: true
|
||||
|
||||
- name: Copy a "nexus data" file on the remote machine to controller host
|
||||
copy:
|
||||
src: "{{ docker_root_directory }}/volumes/{{ nexus_backup_volume_name }}/_data/"
|
||||
dest: "{{ nexus_destination_backup_dir }}"
|
||||
directory_mode: true
|
||||
remote_src: yes
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
# download images
|
||||
- name: Docker module dependency | Login and pull image
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
force_apt_get: yes
|
||||
with_items:
|
||||
- python3-docker
|
||||
- docker-compose
|
||||
register: apt_action
|
||||
retries: 100
|
||||
until: apt_action is success or ('Failed to lock apt for exclusive operation' not in apt_action.msg and '/var/lib/dpkg/lock' not in apt_action.msg)
|
||||
|
||||
- name: docker images pull
|
||||
docker_image:
|
||||
name: "{{ item }}"
|
||||
source: pull
|
||||
with_items:
|
||||
- "{{ TRAEFIK_IMAGE }}:{{ TRAEFIK_VERSION }}"
|
||||
- "{{ NEXUS_IMAGE }}:{{ NEXUS_VERSION }}"
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
- name: pull all image
|
||||
include: image-pull.yaml
|
||||
|
||||
- name: config and setup all service
|
||||
include: repo-setup.yaml
|
||||
|
||||
#- name: get volumes backup
|
||||
# include: get-backup.yaml
|
||||
# tags: repo_get_backup
|
||||
@@ -0,0 +1,45 @@
|
||||
---
|
||||
- name: Creates directory
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
loop:
|
||||
- "{{ REPO_DIRE_NAME }}"
|
||||
- "{{ REPO_DIRE_NAME }}/traefik"
|
||||
- "{{ REPO_DIRE_NAME }}/traefik/certs"
|
||||
|
||||
- name: copy bash script
|
||||
template:
|
||||
src: nexus-setup-with-api.sh.j2
|
||||
dest: "{{ REPO_DIRE_NAME }}/nexus-setup-with-api.sh"
|
||||
|
||||
- name: Copy trafik config file.
|
||||
template:
|
||||
src: traefik.yaml.j2
|
||||
dest: "{{ REPO_DIRE_NAME }}/traefik/config.yml"
|
||||
|
||||
- name: copy Docker Compose files
|
||||
template:
|
||||
src: docker-compose.yaml.j2
|
||||
dest: "{{ REPO_DIRE_NAME }}/docker-compose.yaml"
|
||||
|
||||
#- name: Build the docker-compose stack
|
||||
# shell: docker compose -f "{{ REPO_DIRE_NAME }}"/docker-compose.yaml up -d
|
||||
|
||||
- name: Run `docker-compose up` again
|
||||
docker_compose:
|
||||
project_src: "{{ REPO_DIRE_NAME }}"
|
||||
build: no
|
||||
files:
|
||||
- docker-compose.yaml
|
||||
register: output
|
||||
|
||||
- debug:
|
||||
var: output
|
||||
|
||||
- name: Pause for 2 minutes to run nexus service
|
||||
pause:
|
||||
minutes: 2
|
||||
|
||||
- name: Execute the script
|
||||
command: bash "{{ REPO_DIRE_NAME }}/nexus-setup-with-api.sh"
|
||||
Reference in New Issue
Block a user