split playbook into roles
This commit is contained in:
parent
53bba1751e
commit
62f014d90f
9 changed files with 69 additions and 64 deletions
4
Makefile
4
Makefile
|
@ -1,4 +1,4 @@
|
|||
run:
|
||||
ansible-playbook playbooks/nucs.yml -i inventory/hosts.yml --ask-vault-pass
|
||||
%:
|
||||
ansible-playbook playbooks/$@.yml -i inventory/hosts.yml --ask-vault-pass
|
||||
|
||||
.PHONY: run
|
||||
|
|
9
playbooks/all.yml
Normal file
9
playbooks/all.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
- name: Install pizzeria static website
|
||||
hosts: nucs
|
||||
roles:
|
||||
- pizzeria
|
||||
- name: Install Syncthing
|
||||
hosts: nucs
|
||||
roles:
|
||||
- syncthing
|
|
@ -1,62 +0,0 @@
|
|||
---
|
||||
- name: Setup ansible
|
||||
hosts: nucs
|
||||
tasks:
|
||||
- name: Create Ansible directory
|
||||
file:
|
||||
path: /ansible
|
||||
state: directory
|
||||
- name: Install essential packages
|
||||
apt:
|
||||
pkg:
|
||||
- python3-pip
|
||||
state: latest
|
||||
update_cache: true
|
||||
- name: Install Docker
|
||||
hosts: nucs
|
||||
tasks:
|
||||
- name: Install prerequisites
|
||||
apt:
|
||||
pkg:
|
||||
- ca-certificates
|
||||
- curl
|
||||
- gnupg
|
||||
- lsb-release
|
||||
state: latest
|
||||
update_cache: true
|
||||
- name: Add Docker APT key
|
||||
apt_key:
|
||||
url: https://download.docker.com/linux/ubuntu/gpg
|
||||
- name: Add Docker repository
|
||||
apt_repository:
|
||||
repo: deb https://download.docker.com/linux/ubuntu focal stable # TODO: parameterize distro
|
||||
- name: Install Docker packages
|
||||
apt:
|
||||
pkg:
|
||||
- docker-ce
|
||||
- docker-ce-cli
|
||||
- containerd.io
|
||||
- docker-compose-plugin
|
||||
state: latest
|
||||
update_cache: true
|
||||
- name: Install Docker module for Python
|
||||
pip:
|
||||
name:
|
||||
- docker
|
||||
- docker-compose
|
||||
- name: Install pizzeria static website
|
||||
hosts: nucs
|
||||
tasks:
|
||||
- name: Clone pizzeria repository
|
||||
git:
|
||||
repo: https://github.com/pizzapim/pizzeria
|
||||
dest: /ansible/pizzeria
|
||||
- name: Start the Docker compose
|
||||
community.docker.docker_compose:
|
||||
project_src: /ansible/pizzeria
|
||||
pull: true
|
||||
remove_orphans: true
|
||||
- name: Install Syncthing
|
||||
hosts: nucs
|
||||
roles:
|
||||
- syncthing
|
4
playbooks/pizzeria.yml
Normal file
4
playbooks/pizzeria.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
- name: Install pizzeria static website
|
||||
hosts: nucs
|
||||
roles:
|
||||
- pizzeria
|
4
playbooks/syncthing.yml
Normal file
4
playbooks/syncthing.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
- name: Install syncthing
|
||||
hosts: nucs
|
||||
roles:
|
||||
- syncthing
|
8
roles/common/tasks/main.yml
Normal file
8
roles/common/tasks/main.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
- name: Create /data directory
|
||||
file:
|
||||
path: /data
|
||||
state: directory
|
||||
- name: Create /apps directory
|
||||
file:
|
||||
path: /apps
|
||||
state: directory
|
30
roles/docker/tasks/main.yml
Normal file
30
roles/docker/tasks/main.yml
Normal file
|
@ -0,0 +1,30 @@
|
|||
- name: Install Docker prerequisites
|
||||
apt:
|
||||
pkg:
|
||||
- ca-certificates
|
||||
- curl
|
||||
- gnupg
|
||||
- lsb-release
|
||||
- python3-pip
|
||||
state: latest
|
||||
update_cache: true
|
||||
- name: Add Docker APT key
|
||||
apt_key:
|
||||
url: https://download.docker.com/linux/ubuntu/gpg
|
||||
- name: Add Docker repository
|
||||
apt_repository:
|
||||
repo: "deb https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
|
||||
- name: Install Docker packages
|
||||
apt:
|
||||
pkg:
|
||||
- docker-ce
|
||||
- docker-ce-cli
|
||||
- containerd.io
|
||||
- docker-compose-plugin
|
||||
state: latest
|
||||
update_cache: true
|
||||
- name: Install Docker modules for Python
|
||||
pip:
|
||||
name:
|
||||
- docker
|
||||
- docker-compose
|
3
roles/pizzeria/meta/main.yml
Normal file
3
roles/pizzeria/meta/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
dependencies:
|
||||
- role: common
|
||||
- role: docker
|
9
roles/pizzeria/tasks/main.yml
Normal file
9
roles/pizzeria/tasks/main.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
- name: Clone pizzeria repository
|
||||
git:
|
||||
repo: https://github.com/pizzapim/pizzeria
|
||||
dest: /apps/pizzeria
|
||||
- name: Start the Docker compose
|
||||
community.docker.docker_compose:
|
||||
project_src: /apps/pizzeria
|
||||
pull: true
|
||||
remove_orphans: true
|
Reference in a new issue