adding formatting
parent
e644a03958
commit
4f3e9b552c
@ -1,25 +1,24 @@
|
|||||||
---
|
|
||||||
# all encrypted variables should go in the linked file.
|
# all encrypted variables should go in the linked file.
|
||||||
vault_file: vault_vars/linode-vault.yml
|
vault_file: vault_vars/linode-vault.yml
|
||||||
# any linode specific variables go here
|
# any linode specific variables go here
|
||||||
services:
|
services:
|
||||||
- name: gitea
|
- name: gitea
|
||||||
- name: mealie
|
- name: mealie
|
||||||
- name: linkding
|
- name: linkding
|
||||||
- name: overseerr
|
- name: overseerr
|
||||||
- name: nextcloud
|
- name: nextcloud
|
||||||
- name: nginx-proxy-manager
|
- name: nginx-proxy-manager
|
||||||
- name: uptime-kuma
|
- name: uptime-kuma
|
||||||
- name: docker-volume-backup
|
- name: docker-volume-backup
|
||||||
- name: mariadb
|
- name: mariadb
|
||||||
- name: photoprism
|
- name: photoprism
|
||||||
- name: olivetin
|
- name: olivetin
|
||||||
|
|
||||||
# any additional docker networks that should be created
|
# any additional docker networks that should be created
|
||||||
docker_networks:
|
docker_networks:
|
||||||
- mariadb_net
|
- mariadb_net
|
||||||
|
|
||||||
# use docker compose
|
# use docker compose
|
||||||
container_deployment_mode: "compose"
|
container_deployment_mode: compose
|
||||||
|
|
||||||
restore_from_s3: false
|
restore_from_s3: false
|
||||||
|
|||||||
@ -1,54 +1,53 @@
|
|||||||
---
|
|
||||||
- name: Update packages and ensure users on all hosts
|
- name: Update packages and ensure users on all hosts
|
||||||
tags: ["always"]
|
tags: [always]
|
||||||
hosts: all
|
hosts: all
|
||||||
become: true
|
become: true
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
- name: Update Packages
|
- name: Update Packages
|
||||||
apt:
|
apt:
|
||||||
upgrade: dist
|
upgrade: dist
|
||||||
update_cache: true
|
update_cache: true
|
||||||
roles:
|
roles:
|
||||||
- role: setup_users
|
- role: setup_users
|
||||||
|
|
||||||
- name: Install docker on docker hosts
|
- name: Install docker on docker hosts
|
||||||
hosts: dockerhosts
|
hosts: dockerhosts
|
||||||
become: true
|
become: true
|
||||||
roles:
|
roles:
|
||||||
- role: setup_docker
|
- role: setup_docker
|
||||||
tags: ["setup","docker"]
|
tags: [setup, docker]
|
||||||
|
|
||||||
- name: Setup and deploy services on the QNAP
|
- name: Setup and deploy services on the QNAP
|
||||||
hosts: qnap
|
hosts: qnap
|
||||||
become: true
|
become: true
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
- name: Include vault variables.
|
- name: Include vault variables.
|
||||||
include_vars: "{{vault_file}}"
|
include_vars: '{{vault_file}}'
|
||||||
tags: ["always"]
|
tags: [always]
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- role: setup_mergerfs
|
- role: setup_mergerfs
|
||||||
tags: ["mergerfs"]
|
tags: [mergerfs]
|
||||||
- role: setup_samba
|
- role: setup_samba
|
||||||
tags: ["samba"]
|
tags: [samba]
|
||||||
- role: setup_portainer
|
- role: setup_portainer
|
||||||
tags: ["services", "portainer"]
|
tags: [services, portainer]
|
||||||
- role: setup_hosted_services
|
- role: setup_hosted_services
|
||||||
tags: ["services"]
|
tags: [services]
|
||||||
|
|
||||||
|
|
||||||
- hosts: linodes
|
- hosts: linodes
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
- name: Include vault variables.
|
- name: Include vault variables.
|
||||||
include_vars: "{{vault_file}}"
|
include_vars: '{{vault_file}}'
|
||||||
tags: ["always"]
|
tags: [always]
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- role: setup_samba
|
- role: setup_samba
|
||||||
tags: ["samba"]
|
tags: [samba]
|
||||||
- role: setup_docker
|
- role: setup_docker
|
||||||
tags: ["docker"]
|
tags: [docker]
|
||||||
- role: setup_hosted_services
|
- role: setup_hosted_services
|
||||||
tags: ["services"]
|
tags: [services]
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
---
|
|
||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
become: true
|
become: true
|
||||||
roles:
|
roles:
|
||||||
- role: 'roles/setup_linode'
|
- role: roles/setup_linode
|
||||||
vars:
|
vars:
|
||||||
state: present
|
state: present
|
||||||
|
|||||||
@ -1,48 +1,48 @@
|
|||||||
- hosts: all
|
- hosts: all
|
||||||
become: true
|
become: true
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
- name: Include vault variables.
|
- name: Include vault variables.
|
||||||
include_vars: '../{{vault_file}}'
|
include_vars: ../{{vault_file}}
|
||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
tasks:
|
tasks:
|
||||||
- name: Docker Compose Files Exist
|
- name: Docker Compose Files Exist
|
||||||
command: >-
|
command: >-
|
||||||
stat {{directories.docker_compose_directory}}/{{ item.name }}/docker-compose.yml
|
stat {{directories.docker_compose_directory}}/{{ item.name }}/docker-compose.yml
|
||||||
with_items: '{{services}}'
|
with_items: '{{services}}'
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: docker_compose_stat
|
register: docker_compose_stat
|
||||||
|
|
||||||
- name: Assert all Docker Compose files were created
|
- name: Assert all Docker Compose files were created
|
||||||
assert:
|
assert:
|
||||||
that: item.rc == 0
|
that: item.rc == 0
|
||||||
with_items: '{{docker_compose_stat.results}}'
|
with_items: '{{docker_compose_stat.results}}'
|
||||||
|
|
||||||
- name: Populate service facts
|
- name: Populate service facts
|
||||||
service_facts: {}
|
service_facts: {}
|
||||||
- name: Assert docker is installed and started
|
- name: Assert docker is installed and started
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- ansible_facts.services.docker.state == "running"
|
- ansible_facts.services.docker.state == "running"
|
||||||
- ansible_facts.services['docker.service'].status == "enabled"
|
- ansible_facts.services['docker.service'].status == "enabled"
|
||||||
- name: Inspect all images
|
- name: Inspect all images
|
||||||
docker_image_info: {}
|
docker_image_info: {}
|
||||||
register: image_details
|
register: image_details
|
||||||
- name: Assert desired images exist
|
- name: Assert desired images exist
|
||||||
assert:
|
assert:
|
||||||
that: {{item in image_details.images | map(attribute='RepoTags') | flatten }}
|
that: {{item in image_details.images | map(attribute='RepoTags') | flatten: !!null ''}: !!null ''}
|
||||||
with_items: '{{desired_docker_images}}'
|
with_items: '{{desired_docker_images}}'
|
||||||
|
|
||||||
- name: Fetch Sudoers Files
|
- name: Fetch Sudoers Files
|
||||||
command: 'stat /etc/sudoers.d/{{item.name}}'
|
command: stat /etc/sudoers.d/{{item.name}}
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: sudoers_stat
|
register: sudoers_stat
|
||||||
with_items: '{{users}}'
|
with_items: '{{users}}'
|
||||||
when: item.passwordless_sudo == true
|
when: item.passwordless_sudo == true
|
||||||
|
|
||||||
- name: Assert sudoers files are created
|
- name: Assert sudoers files are created
|
||||||
assert:
|
assert:
|
||||||
that: item.rc == 0
|
that: item.rc == 0
|
||||||
with_items: '{{sudoers_stat.results}}'
|
with_items: '{{sudoers_stat.results}}'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1 +1,2 @@
|
|||||||
---
|
null
|
||||||
|
...
|
||||||
|
|||||||
@ -1,23 +1,23 @@
|
|||||||
# Listen on all addresses available, port 1337
|
# Listen on all addresses available, port 1337
|
||||||
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
|
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
|
||||||
# Choose from INFO (default), WARN and DEBUG
|
# Choose from INFO (default), WARN and DEBUG
|
||||||
logLevel: "INFO"
|
logLevel: INFO
|
||||||
# Actions (buttons) to show up on the WebUI:
|
# Actions (buttons) to show up on the WebUI:
|
||||||
actions:
|
actions:
|
||||||
# Docs: https://docs.olivetin.app/action-container-control.html
|
# Docs: https://docs.olivetin.app/action-container-control.html
|
||||||
- title: Restart Plex
|
- title: Restart Plex
|
||||||
icon: plex
|
icon: plex
|
||||||
shell: docker restart plex
|
shell: docker restart plex
|
||||||
timeout: 30
|
timeout: 30
|
||||||
- title: Restart Dashy
|
- title: Restart Dashy
|
||||||
icon: restart
|
icon: restart
|
||||||
shell: docker restart dashy
|
shell: docker restart dashy
|
||||||
timeout: 30
|
timeout: 30
|
||||||
- title: Restart Dashy 2
|
- title: Restart Dashy 2
|
||||||
icon: restart
|
icon: restart
|
||||||
shell: docker restart dashy
|
shell: docker restart dashy
|
||||||
timeout: 30
|
timeout: 30
|
||||||
- title: Restart Olivetin
|
- title: Restart Olivetin
|
||||||
icon: restart
|
icon: restart
|
||||||
shell: docker restart olivetin
|
shell: docker restart olivetin
|
||||||
timeout: 30
|
timeout: 30
|
||||||
|
|||||||
@ -1,122 +1,125 @@
|
|||||||
---
|
|
||||||
- name: Docker | Pull images
|
- name: Docker | Pull images
|
||||||
docker_image:
|
docker_image:
|
||||||
name: "{{item}}"
|
name: '{{item}}'
|
||||||
source: pull
|
source: pull
|
||||||
with_items:
|
with_items:
|
||||||
- ubuntu
|
- ubuntu
|
||||||
- busybox
|
- busybox
|
||||||
|
|
||||||
- name: Docker Compose | Create a directory if it does not exist
|
- name: Docker Compose | Create a directory if it does not exist
|
||||||
file:
|
file:
|
||||||
path: "{{directories.docker_compose_directory}}/{{item.name}}"
|
path: '{{directories.docker_compose_directory}}/{{item.name}}'
|
||||||
state: directory
|
state: directory
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
with_items: "{{services}}"
|
with_items: '{{services}}'
|
||||||
|
|
||||||
- name: Docker Compose | Template Docker Compose Files
|
- name: Docker Compose | Template Docker Compose Files
|
||||||
template:
|
template:
|
||||||
src: "{{item.name}}.j2"
|
src: '{{item.name}}.j2'
|
||||||
dest: "{{directories.docker_compose_directory}}/{{item.name}}/docker-compose.yml"
|
dest: '{{directories.docker_compose_directory}}/{{item.name}}/docker-compose.yml'
|
||||||
with_items: "{{services}}"
|
with_items: '{{services}}'
|
||||||
|
|
||||||
|
|
||||||
- name: Directories | Ensure required directories
|
- name: Directories | Ensure required directories
|
||||||
file:
|
file:
|
||||||
path: "{{item}}"
|
path: '{{item}}'
|
||||||
state: directory
|
state: directory
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
with_items:
|
with_items:
|
||||||
- "{{dashy.config_directory}}"
|
- '{{dashy.config_directory}}'
|
||||||
- "{{olivetin.config_directory}}"
|
- '{{olivetin.config_directory}}'
|
||||||
- "{{dockervolumebackup.config_directory}}"
|
- '{{dockervolumebackup.config_directory}}'
|
||||||
- "{{directories.backups_dir}}/.s3tmp"
|
- '{{directories.backups_dir}}/.s3tmp'
|
||||||
|
|
||||||
- name: Dashy | Config Files
|
- name: Dashy | Config Files
|
||||||
copy:
|
copy:
|
||||||
src: "{{dashy.source_file}}"
|
src: '{{dashy.source_file}}'
|
||||||
dest: "{{dashy.config_directory}}/{{dashy.config_file}}"
|
dest: '{{dashy.config_directory}}/{{dashy.config_file}}'
|
||||||
notify:
|
notify:
|
||||||
- restart-dashy
|
- restart-dashy
|
||||||
|
|
||||||
- name: Olivetin | Config Files
|
- name: Olivetin | Config Files
|
||||||
copy:
|
copy:
|
||||||
src: "{{olivetin.source_file}}"
|
src: '{{olivetin.source_file}}'
|
||||||
dest: "{{olivetin.config_directory}}/{{olivetin.config_file}}"
|
dest: '{{olivetin.config_directory}}/{{olivetin.config_file}}'
|
||||||
notify:
|
notify:
|
||||||
- restart-olivetin
|
- restart-olivetin
|
||||||
|
|
||||||
- name: Docker Volume Backup | Config Files
|
- name: Docker Volume Backup | Config Files
|
||||||
template:
|
template:
|
||||||
src: "docker-volume-backup/config.j2"
|
src: docker-volume-backup/config.j2
|
||||||
dest: "{{dockervolumebackup.config_directory}}/config.yml"
|
dest: '{{dockervolumebackup.config_directory}}/config.yml'
|
||||||
notify:
|
notify:
|
||||||
- restart-docker-volume-backup
|
- restart-docker-volume-backup
|
||||||
|
|
||||||
- name: Install python dependencies (requests)
|
- name: Install python dependencies (requests)
|
||||||
pip:
|
pip:
|
||||||
name: requests
|
name: requests
|
||||||
|
|
||||||
- name: Docker | Find docker volumes
|
- name: Docker | Find docker volumes
|
||||||
shell: docker volume ls -f name={{item.name}} --format '{{ '{{' }} .Name {{ '}}' }}'
|
shell: docker volume ls -f name={{item.name}} --format '{{ '{{' }} .Name {{ '}}'
|
||||||
with_items: "{{services}}"
|
}}'
|
||||||
|
with_items: '{{services}}'
|
||||||
register: find_volumes
|
register: find_volumes
|
||||||
changed_when: False
|
changed_when: false
|
||||||
|
|
||||||
- debug: msg="{{find_volumes.results | map(attribute='stdout_lines') | list | flatten }}"
|
- debug: msg="{{find_volumes.results | map(attribute='stdout_lines') | list | flatten
|
||||||
|
}}"
|
||||||
|
|
||||||
- name: Docker | Find volumes that need to be restored
|
- name: Docker | Find volumes that need to be restored
|
||||||
script: scripts/find-volumes-to-restore.py
|
script: scripts/find-volumes-to-restore.py
|
||||||
environment:
|
environment:
|
||||||
EXISTING_VOLUMES: "{{ find_volumes.results | map(attribute='stdout_lines') | list | flatten }}"
|
EXISTING_VOLUMES: "{{ find_volumes.results | map(attribute='stdout_lines') | list\
|
||||||
SERVICES: "{{ services }}"
|
\ | flatten }}"
|
||||||
DOCKER_COMPOSE_DIR: "{{directories.docker_compose_directory}}"
|
SERVICES: '{{ services }}'
|
||||||
|
DOCKER_COMPOSE_DIR: '{{directories.docker_compose_directory}}'
|
||||||
args:
|
args:
|
||||||
executable: python3
|
executable: python3
|
||||||
register: python_output
|
register: python_output
|
||||||
changed_when: False
|
changed_when: false
|
||||||
|
|
||||||
- debug: msg="{{python_output.stdout_lines | list }}"
|
- debug: msg="{{python_output.stdout_lines | list }}"
|
||||||
|
|
||||||
- name: Docker Volume Backup | Restore any missing backups from S3
|
- name: Docker Volume Backup | Restore any missing backups from S3
|
||||||
when: restore_from_s3
|
when: restore_from_s3
|
||||||
docker_container:
|
docker_container:
|
||||||
command: "restore-volume --s3 --volume {{item}}"
|
command: restore-volume --s3 --volume {{item}}
|
||||||
image: "ghcr.io/chatton/docker-volume-backup:v0.3.0"
|
image: ghcr.io/chatton/docker-volume-backup:v0.3.0
|
||||||
name: "s3-restore-{{item}}"
|
name: s3-restore-{{item}}
|
||||||
cleanup: true # delete container after it's done.
|
cleanup: true # delete container after it's done.
|
||||||
state: started # container should execute.
|
state: started # container should execute.
|
||||||
detach: no # task fails if container exits.
|
detach: no # task fails if container exits.
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
- /tmp:/tmp # temp s3 archive goes here
|
- /tmp:/tmp # temp s3 archive goes here
|
||||||
env:
|
env:
|
||||||
AWS_ACCESS_KEY_ID: "{{aws_s3.aws_access_key}}"
|
AWS_ACCESS_KEY_ID: '{{aws_s3.aws_access_key}}'
|
||||||
AWS_SECRET_ACCESS_KEY: "{{aws_s3.aws_secret_key}}"
|
AWS_SECRET_ACCESS_KEY: '{{aws_s3.aws_secret_key}}'
|
||||||
AWS_DEFAULT_REGION: "{{aws_s3.region}}"
|
AWS_DEFAULT_REGION: '{{aws_s3.region}}'
|
||||||
AWS_BUCKET: "{{aws_s3.bucket}}"
|
AWS_BUCKET: '{{aws_s3.bucket}}'
|
||||||
AWS_ENDPOINT: "{{aws_s3.s3_url}}"
|
AWS_ENDPOINT: '{{aws_s3.s3_url}}'
|
||||||
with_items: "{{ python_output.stdout_lines }}"
|
with_items: '{{ python_output.stdout_lines }}'
|
||||||
|
|
||||||
- name: Docker | Create required docker networks
|
- name: Docker | Create required docker networks
|
||||||
docker_network:
|
docker_network:
|
||||||
name: "{{item}}"
|
name: '{{item}}'
|
||||||
with_items: "{{ docker_networks }}"
|
with_items: '{{ docker_networks }}'
|
||||||
|
|
||||||
- name: Portainer | Update Stack
|
- name: Portainer | Update Stack
|
||||||
when: container_deployment_mode == "portainer"
|
when: container_deployment_mode == "portainer"
|
||||||
chatton.portainer.portainer_stack:
|
chatton.portainer.portainer_stack:
|
||||||
username: admin
|
username: admin
|
||||||
password: "{{portainer.password}}"
|
password: '{{portainer.password}}'
|
||||||
docker_compose_file_path: "{{directories.docker_compose_directory}}/{{ item.name }}/docker-compose.yml"
|
docker_compose_file_path: '{{directories.docker_compose_directory}}/{{ item.name
|
||||||
stack_name: "{{ item.name }}"
|
}}/docker-compose.yml'
|
||||||
endpoint_id: "{{ item.endpoint_id }}"
|
stack_name: '{{ item.name }}'
|
||||||
|
endpoint_id: '{{ item.endpoint_id }}'
|
||||||
state: present
|
state: present
|
||||||
with_items: "{{services}}"
|
with_items: '{{services}}'
|
||||||
|
|
||||||
- name: Docker compose | Update Stack
|
- name: Docker compose | Update Stack
|
||||||
when: container_deployment_mode == "compose"
|
when: container_deployment_mode == "compose"
|
||||||
docker_compose:
|
docker_compose:
|
||||||
project_src: "{{directories.docker_compose_directory}}/{{ item.name }}"
|
project_src: '{{directories.docker_compose_directory}}/{{ item.name }}'
|
||||||
state: present
|
state: present
|
||||||
with_items: "{{services}}"
|
with_items: '{{services}}'
|
||||||
|
|||||||
@ -1,12 +1,7 @@
|
|||||||
$ANSIBLE_VAULT;1.1;AES256
|
$ANSIBLE_VAULT;1.1;AES256 36356161663039666634393933383830653035633438343866643730303434353632383031303965
|
||||||
36356161663039666634393933383830653035633438343866643730303434353632383031303965
|
3465343332353437616663643662343262373333366162300a373662386533363234636234633339 35383439373430656130353938653531636563663066646265643838323230356231333836326262
|
||||||
3465343332353437616663643662343262373333366162300a373662386533363234636234633339
|
6439626538643837390a383039373366626637333738386332356361306131323133383534323462 32376564376363663666383639313064316365353037356633363035373632313561643030643933
|
||||||
35383439373430656130353938653531636563663066646265643838323230356231333836326262
|
34663533313231636162306465656433663634643038343938396462643261656238626432633136 39356562353463353034373534386537313634326534623830616362336638396337386631663538
|
||||||
6439626538643837390a383039373366626637333738386332356361306131323133383534323462
|
30663236653532316461306636333536373836626537363430613961346137626261333238366234 30633438653936316539326436393634366236616664383835396434373966333166366265636661
|
||||||
32376564376363663666383639313064316365353037356633363035373632313561643030643933
|
39666335653265323565313831303264336331363339333532353939653330383362363965353032 383434386133323961373833303262336439
|
||||||
34663533313231636162306465656433663634643038343938396462643261656238626432633136
|
...
|
||||||
39356562353463353034373534386537313634326534623830616362336638396337386631663538
|
|
||||||
30663236653532316461306636333536373836626537363430613961346137626261333238366234
|
|
||||||
30633438653936316539326436393634366236616664383835396434373966333166366265636661
|
|
||||||
39666335653265323565313831303264336331363339333532353939653330383362363965353032
|
|
||||||
383434386133323961373833303262336439
|
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
---
|
null
|
||||||
# vars file for setup_linode
|
...
|
||||||
|
|||||||
@ -1,17 +1,16 @@
|
|||||||
---
|
|
||||||
version: '3.2'
|
version: '3.2'
|
||||||
services:
|
services:
|
||||||
portainer:
|
portainer:
|
||||||
labels:
|
labels:
|
||||||
ie.cianhatton.backup.enabled: "true"
|
ie.cianhatton.backup.enabled: 'true'
|
||||||
ie.cianhatton.backup.key: "nightly"
|
ie.cianhatton.backup.key: nightly
|
||||||
image: portainer/portainer-ce
|
image: portainer/portainer-ce
|
||||||
container_name: "portainer"
|
container_name: portainer
|
||||||
ports:
|
ports:
|
||||||
- "9000:9000"
|
- 9000:9000
|
||||||
volumes:
|
volumes:
|
||||||
- portainer_data:/data
|
- portainer_data:/data
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
portainer_data:
|
portainer_data:
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
---
|
|
||||||
samba_group: smbgroup
|
samba_group: smbgroup
|
||||||
samba_user: smbuser
|
samba_user: smbuser
|
||||||
users:
|
users:
|
||||||
- name: cianhatton
|
- name: cianhatton
|
||||||
shares:
|
shares:
|
||||||
- /share
|
- /share
|
||||||
- /share/public_files
|
- /share/public_files
|
||||||
- /share/private_files
|
- /share/private_files
|
||||||
- /share/cian_files
|
- /share/cian_files
|
||||||
|
|||||||
@ -1,54 +1,53 @@
|
|||||||
---
|
|
||||||
- name: Install samba packages using apt
|
- name: Install samba packages using apt
|
||||||
apt:
|
apt:
|
||||||
name:
|
name:
|
||||||
- samba
|
- samba
|
||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
|
|
||||||
- name: Ensure samba group exists
|
- name: Ensure samba group exists
|
||||||
ansible.builtin.group:
|
ansible.builtin.group:
|
||||||
name: "{{samba_group}}"
|
name: '{{samba_group}}'
|
||||||
state: present
|
state: present
|
||||||
system: true
|
system: true
|
||||||
notify:
|
notify:
|
||||||
- reload-samba
|
- reload-samba
|
||||||
|
|
||||||
- name: Ensure samba user
|
- name: Ensure samba user
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: "{{samba_user}}"
|
name: '{{samba_user}}'
|
||||||
comment: Samba user
|
comment: Samba user
|
||||||
group: "{{samba_group}}"
|
group: '{{samba_group}}'
|
||||||
shell: /bin/false
|
shell: /bin/false
|
||||||
create_home: false
|
create_home: false
|
||||||
notify:
|
notify:
|
||||||
- reload-samba
|
- reload-samba
|
||||||
|
|
||||||
- name: Add the User(s) to Samba group
|
- name: Add the User(s) to Samba group
|
||||||
user:
|
user:
|
||||||
name: "{{ item.name }}"
|
name: '{{ item.name }}'
|
||||||
groups: "{{ samba_group }}"
|
groups: '{{ samba_group }}'
|
||||||
append: yes
|
append: yes
|
||||||
with_items: "{{users}}"
|
with_items: '{{users}}'
|
||||||
|
|
||||||
- name: Ensure Share directories
|
- name: Ensure Share directories
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{item}}"
|
path: '{{item}}'
|
||||||
recurse: yes
|
recurse: yes
|
||||||
state: directory
|
state: directory
|
||||||
owner: "{{samba_user}}"
|
owner: '{{samba_user}}'
|
||||||
group: "{{samba_group}}"
|
group: '{{samba_group}}'
|
||||||
mode: 'u+rw,g+rw'
|
mode: u+rw,g+rw
|
||||||
with_items: "{{shares}}"
|
with_items: '{{shares}}'
|
||||||
notify:
|
notify:
|
||||||
- reload-samba
|
- reload-samba
|
||||||
|
|
||||||
- name: Copy smb conf files
|
- name: Copy smb conf files
|
||||||
copy:
|
copy:
|
||||||
src: "{{item}}"
|
src: '{{item}}'
|
||||||
dest: "/etc/samba/{{item}}"
|
dest: /etc/samba/{{item}}
|
||||||
with_items:
|
with_items:
|
||||||
- smb.conf
|
- smb.conf
|
||||||
- shares.conf
|
- shares.conf
|
||||||
notify:
|
notify:
|
||||||
- reload-samba
|
- reload-samba
|
||||||
|
|||||||
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function format_dir(){
|
||||||
|
dir="${1}"
|
||||||
|
yaml_files="$(find ${dir} -type f -name "*.yml")"
|
||||||
|
for f in $yaml_files
|
||||||
|
do
|
||||||
|
yamlfmt $f -w
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
format_dir roles
|
||||||
|
format_dir playbooks
|
||||||
|
format_dir host_vars
|
||||||
|
format_dir group_vars
|
||||||
Loading…
Reference in New Issue