Compare commits
6 Commits
main
...
14e09c7ee7
| Author | SHA1 | Date | |
|---|---|---|---|
| 14e09c7ee7 | |||
| 49bd2f630b | |||
| 07b33028d1 | |||
| 4897cdadbd | |||
| e0571783ba | |||
| c633ead7cc |
@@ -1,3 +1,20 @@
|
|||||||
# ansible_home
|
# ansible_home
|
||||||
|
|
||||||
My own home services automation repository
|
## How to use it?
|
||||||
|
|
||||||
|
It's better to use a virtual environment to avoid incompatibility issues
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://git.vmn.su/max/vmn-ansible
|
||||||
|
cd vmn-ansible
|
||||||
|
python3 -m venv .venv
|
||||||
|
source .venv/bin/activate
|
||||||
|
pip install -r requirements.txt
|
||||||
|
ansible-galaxy collection install -r requirements.yaml
|
||||||
|
ansible-galaxy role install -r requirements.yaml
|
||||||
|
ansible-playbook playbooks/deploy_and_set_up_lxc_on_proxmox.yaml --vault-pass-file $VAULT_PASS_PATH -i inventory/localhost.yaml --private-key $SSH_KEY
|
||||||
|
```
|
||||||
|
|
||||||
|
**deploy** playbooks must be used with `inventory/localhost.yaml`, they need access to proxmox host only
|
||||||
|
|
||||||
|
There are also a systemd service and timer under `systemd` directory
|
||||||
|
|||||||
@@ -39,3 +39,11 @@ all:
|
|||||||
ansible_become_password: "{{ ansible_become_passwd }}"
|
ansible_become_password: "{{ ansible_become_passwd }}"
|
||||||
services_to_run:
|
services_to_run:
|
||||||
- coder_ai
|
- coder_ai
|
||||||
|
web-servers:
|
||||||
|
hosts:
|
||||||
|
cert-proxy:
|
||||||
|
ansible_host: 192.168.0.47
|
||||||
|
ansible_become_password: "{{ ansible_become_passwd }}"
|
||||||
|
monitoring:
|
||||||
|
ansible_host: 192.168.0.49
|
||||||
|
ansible_become_password: "{{ ansible_become_passwd }}"
|
||||||
|
|||||||
+12
-1
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
- name: Deploy and set up an LXC container in Proxmox
|
- name: Perform regular maintenance
|
||||||
hosts: virtual
|
hosts: virtual
|
||||||
remote_user: ansible
|
remote_user: ansible
|
||||||
|
|
||||||
@@ -20,3 +20,14 @@
|
|||||||
- ../roles/update_configs
|
- ../roles/update_configs
|
||||||
# Make sure that the services that are supposed to run are running
|
# Make sure that the services that are supposed to run are running
|
||||||
- ../roles/check_services
|
- ../roles/check_services
|
||||||
|
|
||||||
|
- name: Ensure all web-servers have fresh TLS certificates
|
||||||
|
hosts: web-servers
|
||||||
|
remote_user: ansible
|
||||||
|
|
||||||
|
vars_files:
|
||||||
|
../inventory/group_vars/all/secrets.yaml
|
||||||
|
|
||||||
|
roles:
|
||||||
|
# Pull certificates from cert_proxy and distribute them among the servers
|
||||||
|
- ../roles/update_certificates
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# PUT NEW BLOCKS STRICTLY BEFORE ANY MATCH BLOCK
|
||||||
|
|
||||||
|
|
||||||
|
# Private keys are NOT distributed via Ansible
|
||||||
|
# They must to be copied manually ONLY to those hosts that need access to others
|
||||||
|
|
||||||
|
# Most of the home major LAN hosts should be accessible with this key
|
||||||
|
Match 192.168.0.0/24
|
||||||
|
User max
|
||||||
|
IdentityFile ~/.ssh/max_regular_key
|
||||||
|
|
||||||
|
# This virtual network has the same hosts range
|
||||||
|
Match 10.9.2.0/24
|
||||||
|
User max
|
||||||
|
IdentityFile ~/.ssh/max_regular_key
|
||||||
@@ -48,6 +48,15 @@
|
|||||||
group: "{{ human_admin_user }}"
|
group: "{{ human_admin_user }}"
|
||||||
mode: u=rw,g=r,o-rwx
|
mode: u=rw,g=r,o-rwx
|
||||||
|
|
||||||
|
- name: Configure ssh client, by pushing the config
|
||||||
|
remote_user: ansible
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ role_path }}/files/ssh_config"
|
||||||
|
dest: "/home/{{ human_admin_user }}/.ssh/config"
|
||||||
|
owner: "{{ human_admin_user }}"
|
||||||
|
group: "{{ human_admin_user }}"
|
||||||
|
mode: u=rw,g=r,o-rwx
|
||||||
|
|
||||||
|
|
||||||
# WARNING: we've finished with the initial setup, drop ansible key
|
# WARNING: we've finished with the initial setup, drop ansible key
|
||||||
# Push regular user key
|
# Push regular user key
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
- name: Pull directory from remote host to control node
|
||||||
|
ansible.posix.synchronize:
|
||||||
|
mode: pull
|
||||||
|
src: /tmp/letsencrypt
|
||||||
|
dest: /tmp
|
||||||
|
recursive: true
|
||||||
|
delete: true
|
||||||
|
when: "inventory_hostname == 'cert-proxy'"
|
||||||
|
|
||||||
|
- name: Push loki.vmn.su certificate to the target
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: /tmp/letsencrypt/live/loki.vmn.su/fullchain.pem
|
||||||
|
dest: /etc/nginx/certs/loki_fullchain.pem
|
||||||
|
local_follow: true
|
||||||
|
when: "inventory_hostname == 'monitoring'"
|
||||||
|
|
||||||
|
- name: Push loki.vmn.su key to the target
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: /tmp/letsencrypt/live/loki.vmn.su/privkey.pem
|
||||||
|
dest: /etc/nginx/certs/loki_privkey.pem
|
||||||
|
local_follow: true
|
||||||
|
when: "inventory_hostname == 'monitoring'"
|
||||||
Reference in New Issue
Block a user