Skip to content

Commit

Permalink
fixed role structure
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathankingfc committed Apr 19, 2021
1 parent 48b28a9 commit b50ce36
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 115 deletions.
7 changes: 7 additions & 0 deletions install-mirror-appliance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- name: "Install Mirror Appliance"
gather_facts: no
hosts: mirror
tags:
- quay
roles:
- quay_installer
4 changes: 4 additions & 0 deletions inventories/example/hosts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ acnp01.corp.example.com
[redis:vars]
redis_runtime_user=docker-redis


[mirror]
104.197.5.254

# 1+ server(s) marked as is_quay=true
# 0-2 server(s) marked as is_clair=true
[quay]
Expand Down
1 change: 1 addition & 0 deletions roles/quay_installer/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
redis_image: docker.io/centos/redis-5-centos8
postgres_image: docker.io/centos/postgresql-10-centos8
quay_image: quay.io/projectquay/quay:latest
image_archive_path: "{{playbook_dir }}/files/image-archive.yaml"
18 changes: 7 additions & 11 deletions roles/quay_installer/tasks/autodetect-image-archive.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
- name: Autodetecting Image Archive
hosts: all
become: yes
tasks:
- name: Ansible check file exists.
stat:
path: "{{ image-archive-path }}"
register: p
- name: Image Archive Found. Loading Images.
command: "podman load -i {{ image-archive-path }}"
when: p.stat.exists
- name: Ansible check file exists.
stat:
path: "{{ image_archive_path }}"
register: p
- name: Image Archive Found. Loading Images.
command: "podman load -i {{ image_archive_path }}"
when: p.stat.exists
18 changes: 7 additions & 11 deletions roles/quay_installer/tasks/create-podman-pod.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
- name: Create podman pod
hosts: all
become: yes
tasks:
- name: Create podman pod for shared network namespace
containers.podman.podman_pod:
name: quay-pod
state: started
ports:
- 80:8080
- 443:8443
- name: Create podman pod for shared network namespace
containers.podman.podman_pod:
name: quay-pod
state: started
ports:
- 80:8080
- 443:8443
58 changes: 27 additions & 31 deletions roles/quay_installer/tasks/install-postgres-service.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
- name: Install Postgres Service
hosts: postgres
become: yes
tasks:
- name: Create necessary directory for Postgres persistent data
ansible.builtin.file:
path: /etc/quay-install/pg-data
state: directory
recurse: yes
- name: Create necessary directory for Postgres persistent data
ansible.builtin.file:
path: /etc/quay-install/pg-data
state: directory
recurse: yes

- name: Set permissions on data directory
ansible.posix.acl:
path: /etc/quay-install/pg-data
entry: u:26:-wx
state: present
- name: Set permissions on data directory
ansible.posix.acl:
path: /etc/quay-install/pg-data
entry: u:26:-wx
state: present

- name: Copy Postgres systemd service file
template: src=../files/systemd/postgres.service dest=/etc/systemd/system/quay-postgres.service
- name: Copy Postgres systemd service file
template: src=../files/systemd/postgres.service dest=/etc/systemd/system/quay-postgres.service

- name: Pull Postgres image
containers.podman.podman_image:
name: "{{ postgres_image }}"
- name: Pull Postgres image
containers.podman.podman_image:
name: "{{ postgres_image }}"

- name: Start Postgres service
systemd:
name: quay-postgres.service
enabled: yes
daemon_reload: yes
state: started
- name: Start Postgres service
systemd:
name: quay-postgres.service
enabled: yes
daemon_reload: yes
state: started

- name: Wait for pg_trgm to be installed
command: podman exec -it quay-postgresql-service /bin/bash -c "echo 'CREATE EXTENSION IF NOT EXISTS pg_trgm' | psql -d quay -U postgres"
register: result
until: result.rc == 0
retries: 20
delay: 5
- name: Wait for pg_trgm to be installed
command: podman exec -it quay-postgresql-service /bin/bash -c "echo 'CREATE EXTENSION IF NOT EXISTS pg_trgm' | psql -d quay -U postgres"
register: result
until: result.rc == 0
retries: 20
delay: 5
60 changes: 28 additions & 32 deletions roles/quay_installer/tasks/install-quay-service.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
- name: Install Quay Service
hosts: quay
become: yes
tasks:
- name: Create necessary directory for Quay local storage
ansible.builtin.file:
path: /etc/quay-install/quay-storage
state: directory
recurse: yes
- name: Create necessary directory for Quay local storage
ansible.builtin.file:
path: /etc/quay-install/quay-storage
state: directory
recurse: yes

- name: Create necessary directory for Quay config bundle
ansible.builtin.file:
path: /etc/quay-install/quay-config
state: directory
recurse: yes
- name: Create necessary directory for Quay config bundle
ansible.builtin.file:
path: /etc/quay-install/quay-config
state: directory
recurse: yes

- name: Set permissions on local storage directory
ansible.posix.acl:
path: /etc/quay-install/quay-storage
entry: u:1001:-wx
state: present
- name: Set permissions on local storage directory
ansible.posix.acl:
path: /etc/quay-install/quay-storage
entry: u:1001:-wx
state: present

- name: Copy Quay config.yaml file
template: src=../files/quay-config/config.yaml dest=/etc/quay-install/quay-config
- name: Copy Quay config.yaml file
template: src=../files/quay-config/config.yaml dest=/etc/quay-install/quay-config

- name: Copy Quay systemd service file
template: src=../files/systemd/quay.service dest=/etc/systemd/system/quay-app.service
- name: Copy Quay systemd service file
template: src=../files/systemd/quay.service dest=/etc/systemd/system/quay-app.service

- name: Pull Quay image
containers.podman.podman_image:
name: "{{ quay_image }}"
- name: Pull Quay image
containers.podman.podman_image:
name: "{{ quay_image }}"

- name: Start Quay service
systemd:
name: quay-app.service
enabled: yes
daemon_reload: yes
state: started
- name: Start Quay service
systemd:
name: quay-app.service
enabled: yes
daemon_reload: yes
state: started
26 changes: 11 additions & 15 deletions roles/quay_installer/tasks/install-redis-service.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
- name: Install Redis Service
hosts: redis
become: yes
tasks:
- name: Copy Redis systemd service file
template: src=../files/systemd/redis.service dest=/etc/systemd/system/quay-redis.service
- name: Copy Redis systemd service file
template: src=../files/systemd/redis.service dest=/etc/systemd/system/quay-redis.service

- name: Pull Redis image
containers.podman.podman_image:
name: "{{ redis_image }}"
- name: Pull Redis image
containers.podman.podman_image:
name: "{{ redis_image }}"

- name: Start Redis service
systemd:
name: quay-redis.service
enabled: yes
daemon_reload: yes
state: started
- name: Start Redis service
systemd:
name: quay-redis.service
enabled: yes
daemon_reload: yes
state: started
12 changes: 6 additions & 6 deletions roles/quay_installer/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
- name: Set SELinux Rules
import_task: set-selinux-rules.yaml
include_tasks: set-selinux-rules.yaml

- name: Create Podman Pod
import_task: create-podman-pod.yaml
include_tasks: create-podman-pod.yaml

- name: Autodetect Image Archive
import_task: autodetect-image-archive.yaml
include_tasks: autodetect-image-archive.yaml

- name: Install Postgres Service
import_task: install-postgres-service.yaml
include_tasks: install-postgres-service.yaml

- name: Install Redis Service
import_task: install-redis-service.yaml
include_tasks: install-redis-service.yaml

- name: Install Quay Service
import_task: install-quay-service.yaml
include_tasks: install-quay-service.yaml
14 changes: 5 additions & 9 deletions roles/quay_installer/tasks/set-selinux-rules.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
- name: Set SELinux Rules
hosts: all
become: yes
tasks:
- name: Set container_manage_cgroup flag on and keep it persistent across reboots
ansible.posix.seboolean:
name: container_manage_cgroup
state: yes
persistent: yes
- name: Set container_manage_cgroup flag on and keep it persistent across reboots
ansible.posix.seboolean:
name: container_manage_cgroup
state: yes
persistent: yes

0 comments on commit b50ce36

Please sign in to comment.