diff --git a/.ansible/server.yaml b/.ansible/home_server.yaml similarity index 86% rename from .ansible/server.yaml rename to .ansible/home_server.yaml index b31bfe3..ac7a3b5 100644 --- a/.ansible/server.yaml +++ b/.ansible/home_server.yaml @@ -5,3 +5,4 @@ - searx_server - matrix_server - media_server + - traccar_server diff --git a/.ansible/roles/common_server/tasks/basics.yaml b/.ansible/roles/common_server/tasks/basics.yaml index 7afe24d..18572a3 100644 --- a/.ansible/roles/common_server/tasks/basics.yaml +++ b/.ansible/roles/common_server/tasks/basics.yaml @@ -1,8 +1,29 @@ -- name: Basic package installs +- name: 'Basics: Package installs' tags: - install + - basics yum: name: "{{ item }}" state: latest loop: "{{ server_packages }}" - become: true + become: yes + +- name: 'Basics: Directories' + tags: + - basics + file: + path: "{{ item }}" + state: directory + loop: + - /srv + - /srv/app + - /srv/tmp + become: yes + +- name: 'Basics: Temp dir perms' + tags: + - basics + file: + path: '/srv/tmp' + mode: '1777' + become: yes diff --git a/.ansible/roles/common_server/vars/main.yaml b/.ansible/roles/common_server/vars/main.yaml index 781b566..2054f4a 100644 --- a/.ansible/roles/common_server/vars/main.yaml +++ b/.ansible/roles/common_server/vars/main.yaml @@ -1,9 +1,12 @@ server_packages: - git - haproxy + - letsencrypt - lsof - net-tools - psmisc - rsync + - screen - telnet + - unzip - vim diff --git a/.ansible/roles/matrix_server/tasks/main.yaml b/.ansible/roles/matrix_server/tasks/main.yaml new file mode 100644 index 0000000..4ec968e --- /dev/null +++ b/.ansible/roles/matrix_server/tasks/main.yaml @@ -0,0 +1,9 @@ +- name: Synapse package + tags: + - install + - matrix + - synapse + package: + name: matrix-synapse + state: latest + become: yes diff --git a/.ansible/roles/searx_server/tasks/main.yaml b/.ansible/roles/searx_server/tasks/main.yaml new file mode 100644 index 0000000..86a5c8b --- /dev/null +++ b/.ansible/roles/searx_server/tasks/main.yaml @@ -0,0 +1,8 @@ +- name: 'Searx: package' + tags: + - install + - searx + package: + name: searx + state: latest + become: yes diff --git a/.ansible/roles/traccar_server/tasks/install.yaml b/.ansible/roles/traccar_server/tasks/install.yaml new file mode 100644 index 0000000..b1a4b59 --- /dev/null +++ b/.ansible/roles/traccar_server/tasks/install.yaml @@ -0,0 +1,37 @@ +- name: 'Traccar: Temporary file' + tempfile: + state: file + suffix: '.zip' + register: traccarzip + +- name: 'Traccar: Download' + get_url: + url: https://github.com/traccar/traccar/releases/download/v4.5/traccar-linux-64-4.5.zip + dest: "{{ traccarzip.path }}" + force: true + register: fetchurl + +- name: 'Traccar: Install dir' + file: + path: "{{ traccar_tmppath }}" + state: directory + become: yes + +- name: 'Traccar: Unzip' + unarchive: + src: "{{ traccarzip.path }}" + dest: "{{ traccar_tmppath }}" + remote_src: yes + become: yes + +- name: 'Traccar: Remove temporary file' + file: + path: "{{ traccarzip.path }}" + state: absent + +- name: 'Traccar: Run installer' + tags: + - install + - traccar + command: "{{ traccar_tmppath}}/traccar.run" + become: yes diff --git a/.ansible/roles/traccar_server/tasks/main.yaml b/.ansible/roles/traccar_server/tasks/main.yaml new file mode 100644 index 0000000..503b4fd --- /dev/null +++ b/.ansible/roles/traccar_server/tasks/main.yaml @@ -0,0 +1,47 @@ +- name: 'Traccar: Check installed' + tags: + - install + - traccar + stat: + path: "/opt/traccar/traccar.run" + register: traccar_app + +- name: 'Traccar: Install' + tags: + - install + - traccar + include_tasks: + file: install.yaml + apply: + tags: + - always + when: not traccar_app.stat.exists + +- name: 'Traccar: Fix perms' + tags: + - install + - traccar + file: + path: "/opt/traccar" + owner: "{{ traccar_owner }}" + group: "{{ traccar_owner }}" + recurse: yes + become: yes + +- name: 'Traccar: Tidy installer' + tags: + - install + - traccar + file: + path: "{{ traccar_tmppath }}" + state: absent + become: yes + +- name: 'Traccar: Service running' + tags: + - traccar + systemd: + name: traccar + state: started + enabled: yes + become: yes diff --git a/.ansible/roles/traccar_server/vars/main.yaml b/.ansible/roles/traccar_server/vars/main.yaml new file mode 100644 index 0000000..0a05428 --- /dev/null +++ b/.ansible/roles/traccar_server/vars/main.yaml @@ -0,0 +1,2 @@ +traccar_tmppath: '/srv/tmp/traccar' +traccar_owner: 'scott'