Fix linting and add backup cron job (#25)
parent
d49819acec
commit
5cd48b220f
@ -0,0 +1,3 @@
|
|||||||
|
skip_list:
|
||||||
|
- '403' # allow for latest packages
|
||||||
|
- name[casing]
|
||||||
@ -1,6 +1,8 @@
|
|||||||
- hosts: localhost
|
---
|
||||||
|
- name: Setup linode instance.
|
||||||
|
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
|
- name: Verify HomeLab has been correctly set up.
|
||||||
|
hosts: all
|
||||||
become: true
|
become: true
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
- name: Include vault variables.
|
- name: Include vault variables.
|
||||||
include_vars: ../{{vault_file}}
|
ansible.builtin.include_vars: ../{{ vault_file }}
|
||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
tasks:
|
tasks:
|
||||||
- name: Docker Compose Files Exist
|
- name: Docker Compose Files Exist
|
||||||
command: stat {{directories.docker_compose_directory}}/{{ item.name }}/docker-compose.yml
|
ansible.builtin.command: 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:
|
ansible.builtin.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: {}
|
ansible.builtin.service_facts: {}
|
||||||
- name: Assert docker is installed and started
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- ansible_facts.services.docker.state == "running"
|
|
||||||
- ansible_facts.services['docker.service'].status == "enabled"
|
|
||||||
- name: Inspect all images
|
|
||||||
docker_image_info: {}
|
|
||||||
register: image_details
|
|
||||||
- name: Assert desired images exist
|
|
||||||
assert:
|
|
||||||
that: {{item in image_details.images | map(attribute='RepoTags') | flatten: !!null ''}: !!null ''}
|
|
||||||
with_items: '{{desired_docker_images}}'
|
|
||||||
|
|
||||||
- name: Fetch Sudoers Files
|
- name: Assert docker is installed and started
|
||||||
command: stat /etc/sudoers.d/{{item.name}}
|
ansible.builtin.assert:
|
||||||
changed_when: false
|
that:
|
||||||
register: sudoers_stat
|
- ansible_facts.services.docker.state == "running"
|
||||||
with_items: '{{users}}'
|
- ansible_facts.services['docker.service'].status == "enabled"
|
||||||
when: item.passwordless_sudo == true
|
- name: Inspect all images
|
||||||
|
docker_image_info: {}
|
||||||
- name: Assert sudoers files are created
|
register: image_details
|
||||||
assert:
|
- name: Assert desired images exist
|
||||||
that: item.rc == 0
|
ansible.builtin.assert:
|
||||||
with_items: '{{sudoers_stat.results}}'
|
that: "{{ item in image_details.images | map(attribute='RepoTags') | flatten }}"
|
||||||
|
with_items: '{{ desired_docker_images }}'
|
||||||
|
|
||||||
|
- name: Fetch Sudoers Files
|
||||||
|
ansible.builtin.command: stat /etc/sudoers.d/{{ item.name }}
|
||||||
|
changed_when: false
|
||||||
|
register: sudoers_stat
|
||||||
|
with_items: '{{ users }}'
|
||||||
|
when: item.passwordless_sudo
|
||||||
|
|
||||||
|
- name: Assert sudoers files are created
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that: item.rc == 0
|
||||||
|
with_items: '{{ sudoers_stat.results }}'
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
galaxy_info:
|
galaxy_info:
|
||||||
author: Cian Hatton
|
author: Cian Hatton
|
||||||
namespace: chatton
|
namespace: chatton
|
||||||
description: Bootstrap ansible
|
description: Setup Docker
|
||||||
company: your company (optional)
|
|
||||||
license: MIT
|
license: MIT
|
||||||
min_ansible_version: 2.1
|
min_ansible_version: "2.1"
|
||||||
galaxy_tags: []
|
galaxy_tags: []
|
||||||
|
platforms:
|
||||||
|
- name: Debian
|
||||||
|
versions:
|
||||||
|
- all
|
||||||
dependencies: []
|
dependencies: []
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
# handlers file for setup_hosted_services
|
# handlers file for setup_hosted_services
|
||||||
- name: restart-dashy
|
- name: restart-dashy
|
||||||
command: docker restart dashy
|
ansible.builtin.command: docker restart dashy
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: restart-olivetin
|
- name: restart-olivetin
|
||||||
command: docker restart olivetin
|
ansible.builtin.command: docker restart olivetin
|
||||||
|
|
||||||
- name: restart-docker-volume-backup
|
- name: restart-docker-volume-backup
|
||||||
command: docker restart docker-volume-backup
|
ansible.builtin.command: docker restart docker-volume-backup
|
||||||
|
|||||||
@ -1,7 +1,12 @@
|
|||||||
$ANSIBLE_VAULT;1.1;AES256 36356161663039666634393933383830653035633438343866643730303434353632383031303965
|
$ANSIBLE_VAULT;1.1;AES256
|
||||||
3465343332353437616663643662343262373333366162300a373662386533363234636234633339 35383439373430656130353938653531636563663066646265643838323230356231333836326262
|
38343033383061343739363362626366376630376337376639376235316665363736376362633830
|
||||||
6439626538643837390a383039373366626637333738386332356361306131323133383534323462 32376564376363663666383639313064316365353037356633363035373632313561643030643933
|
6638383135303063363866623262303736393337386364630a353533323537376437343033666334
|
||||||
34663533313231636162306465656433663634643038343938396462643261656238626432633136 39356562353463353034373534386537313634326534623830616362336638396337386631663538
|
32353832353466343832643238313834616662333736363738353565623063316438393635343631
|
||||||
30663236653532316461306636333536373836626537363430613961346137626261333238366234 30633438653936316539326436393634366236616664383835396434373966333166366265636661
|
6662366132396337320a326335353333306262666561353037356539633432376439666133386463
|
||||||
39666335653265323565313831303264336331363339333532353939653330383362363965353032 383434386133323961373833303262336439
|
30326230316634346431346266333030303435313065616665656362663164313638313639313633
|
||||||
...
|
63343538653230653330383336386138643636333361326139346336646665366530343537663331
|
||||||
|
61303639313335343162613838303034616362303935653862666166656634613562376330306165
|
||||||
|
32373832666438623638616363363931636664633337396336653237356234616438623261353134
|
||||||
|
62373463313235323233343734363561353237613439663534393537333964323932373837356564
|
||||||
|
32383536613332323532633534306632373762666236366664383636323264363433396437666437
|
||||||
|
323637336362613139633237316237666365
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
|
---
|
||||||
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,53 +1,57 @@
|
|||||||
- name: Install samba packages using apt
|
---
|
||||||
apt:
|
- name: Install samba packages using apt.
|
||||||
|
ansible.builtin.apt:
|
||||||
name:
|
name:
|
||||||
- samba
|
- samba
|
||||||
state: present
|
state: present
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
|
||||||
- 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:
|
ansible.builtin.user:
|
||||||
name: '{{ item.name }}'
|
name: '{{ item.name }}'
|
||||||
groups: '{{ samba_group }}'
|
groups: '{{ samba_group }}'
|
||||||
append: true
|
append: true
|
||||||
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: true
|
recurse: true
|
||||||
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:
|
ansible.builtin.copy:
|
||||||
src: '{{item}}'
|
src: '{{ item }}'
|
||||||
dest: /etc/samba/{{item}}
|
dest: "/etc/samba/{{ item }}"
|
||||||
|
mode: 0644
|
||||||
|
owner: "{{ samba_user }}"
|
||||||
|
group: "{{ samba_group }}"
|
||||||
with_items:
|
with_items:
|
||||||
- smb.conf
|
- smb.conf
|
||||||
- shares.conf
|
- shares.conf
|
||||||
notify:
|
notify:
|
||||||
- reload-samba
|
- reload-samba
|
||||||
|
|||||||
@ -1,39 +1,42 @@
|
|||||||
# https://stackoverflow.com/questions/37333305/ansible-create-a-user-with-sudo-privileges
|
# https://stackoverflow.com/questions/37333305/ansible-create-a-user-with-sudo-privileges
|
||||||
- name: Install Sudo
|
- name: Install Sudo.
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
pkg:
|
pkg:
|
||||||
- sudo
|
- sudo
|
||||||
state: latest
|
state: latest
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
|
||||||
- name: Make sure we have a groups
|
- name: Make sure we have a groups.
|
||||||
group:
|
ansible.builtin.group:
|
||||||
name: '{{ item.group }}'
|
name: '{{ item.group }}'
|
||||||
state: present
|
state: present
|
||||||
with_items: '{{ users }}'
|
with_items: '{{ users }}'
|
||||||
|
|
||||||
- name: Add Users
|
- name: Add Users.
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: '{{ item.name }}'
|
name: '{{ item.name }}'
|
||||||
comment: '{{ item.name }} user'
|
comment: '{{ item.name }} user'
|
||||||
group: '{{ item.group }}'
|
group: '{{ item.group }}'
|
||||||
with_items: '{{ users }}'
|
with_items: '{{ users }}'
|
||||||
|
|
||||||
- name: Add sudoers
|
- name: Add sudoers.
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: sudoers.j2
|
src: sudoers.j2
|
||||||
dest: /etc/sudoers.d/{{item.name}}
|
dest: /etc/sudoers.d/{{ item.name }}
|
||||||
mode: 0440
|
mode: 0440
|
||||||
with_items: '{{ users }}'
|
with_items: '{{ users }}'
|
||||||
when: item.passwordless_sudo == true
|
when: item.passwordless_sudo
|
||||||
|
|
||||||
- name: Set authorized key
|
- name: Set authorized key.
|
||||||
authorized_key:
|
authorized_key:
|
||||||
user: '{{ homelab_user }}'
|
user: '{{ homelab_user }}'
|
||||||
state: present
|
state: present
|
||||||
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
|
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
|
||||||
|
|
||||||
- name: Copy Bashrc
|
- name: Copy Bashrc.
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: bash_rc
|
src: bash_rc
|
||||||
dest: "/home/{{ homelab_user }}/.bash_rc"
|
dest: "/home/{{ homelab_user }}/.bash_rc"
|
||||||
|
group: "{{ homelab_user }}"
|
||||||
|
owner: "{{ homelab_user }}"
|
||||||
|
mode: 0644
|
||||||
|
|||||||
Loading…
Reference in New Issue