diff options
author | Aaditya Dhruv <[email protected]> | 2023-09-10 13:12:57 -0500 |
---|---|---|
committer | Aaditya Dhruv <[email protected]> | 2023-09-10 13:12:57 -0500 |
commit | 2c4e604049ef625049d1fbb6ad241dffea800bea (patch) | |
tree | d05f77d7ea5d7df77277af60681673bfd77c13cf | |
parent | 58169328b1ed3b5c2d47ab917d2f9eca9548c15b (diff) |
Add system roles
System roles handle system level configuration like systemd services,
wireguard etc.
-rw-r--r-- | src/system/files/dnf.conf | 9 | ||||
-rw-r--r-- | src/system/files/dnf/dnf.conf | 9 | ||||
-rw-r--r-- | src/system/files/systemd/sys/wireguard.service | 14 | ||||
-rw-r--r-- | src/system/files/systemd/user/syncthing.service | 13 | ||||
-rw-r--r-- | src/system/tasks/main.yaml | 46 | ||||
-rw-r--r-- | src/system/vars/main.yaml | 2 |
6 files changed, 93 insertions, 0 deletions
diff --git a/src/system/files/dnf.conf b/src/system/files/dnf.conf new file mode 100644 index 0000000..a3f55fb --- /dev/null +++ b/src/system/files/dnf.conf @@ -0,0 +1,9 @@ +[main] +gpgcheck=1 +installonly_limit=3 +clean_requirements_on_remove=True +best=False +skip_if_unavailable=True +defaultyes=True +max_parallel_downloads=10 +deltarpm=True diff --git a/src/system/files/dnf/dnf.conf b/src/system/files/dnf/dnf.conf new file mode 100644 index 0000000..a3f55fb --- /dev/null +++ b/src/system/files/dnf/dnf.conf @@ -0,0 +1,9 @@ +[main] +gpgcheck=1 +installonly_limit=3 +clean_requirements_on_remove=True +best=False +skip_if_unavailable=True +defaultyes=True +max_parallel_downloads=10 +deltarpm=True diff --git a/src/system/files/systemd/sys/wireguard.service b/src/system/files/systemd/sys/wireguard.service new file mode 100644 index 0000000..76a2968 --- /dev/null +++ b/src/system/files/systemd/sys/wireguard.service @@ -0,0 +1,14 @@ +[Unit] +Description=Wireguard +After=network-online.target +Wants=network-online.target + +[Service] +Type=oneshot +RemainAfterExit=true +User=root +ExecStart=/usr/bin/wg-quick up wg0 +ExecStop=/usr/bin/wg-quick down wg0 + +[Install] +WantedBy=multi-user.target diff --git a/src/system/files/systemd/user/syncthing.service b/src/system/files/systemd/user/syncthing.service new file mode 100644 index 0000000..67fa2cd --- /dev/null +++ b/src/system/files/systemd/user/syncthing.service @@ -0,0 +1,13 @@ +[Unit] +Description=Syncthing podman container +After=network-online.target +Wants=network-online.target + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStart=/usr/bin/podman-compose -f /home/aaditya/containers/syncthing/compose.yaml up -d +ExecStop=/usr/bin/podman-compose -f /home/aaditya/containers/syncthing/compose.yaml down + +[Install] +WantedBy=multi-user.target diff --git a/src/system/tasks/main.yaml b/src/system/tasks/main.yaml new file mode 100644 index 0000000..f03c02b --- /dev/null +++ b/src/system/tasks/main.yaml @@ -0,0 +1,46 @@ +- name: Wireguard Setup + block: + - name: Install Wireguard + ansible.builtin.dnf: + name: wireguard-tools + state: latest + - name: Copy Wireguard configuartion + ansible.builtin.copy: + src: "{{ config.system.wireguard.wg_path }}" + dest: /etc/wireguard/ + backup: yes + - name: Setup WG Systemd service + ansible.builtin.copy: + src: "systemd/sys/wireguard.service" + dest: /etc/systemd/system/ + backup: yes + - name: Enable wireguard service + systemd: + state: started + name: wireguard.service + when: 'config.system.install_wireguard' + +- name: Systemd setups + block: + - name: Copying user systemd configs + ansible.builtin.copy: + src: "systemd/user/{{ item }}.service" + dest: "/home/{{ config.username }}/.config/systemd/user/" + loop: "{{ systemd }}" + + - name: Enable service + become: yes + become_user: aaditya + systemd: + scope: user + state: started + name: "{{ item }}.service" + loop: "{{ systemd }}" + when: 'config.system.install_systemd' + + +- name: Setup DNF conf + ansible.builtin.copy: + src: "dnf/dnf.conf" + dest: /etc/dnf/dnf.conf + backup: yes diff --git a/src/system/vars/main.yaml b/src/system/vars/main.yaml new file mode 100644 index 0000000..1f2da1e --- /dev/null +++ b/src/system/vars/main.yaml @@ -0,0 +1,2 @@ +systemd: + - syncthing |