Skip to content

Commit

Permalink
feat(supervised_install): Pull static config files from source (#18)
Browse files Browse the repository at this point in the history
Remove the static files and and templates from the `supervised_install` role and pull them directly from the master branch of the supervised installer repo so that they are always up to date.

Fixes #17
  • Loading branch information
jhampson-dbre authored Feb 2, 2021
1 parent 03d5d3a commit 8734182
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 159 deletions.
6 changes: 5 additions & 1 deletion roles/supervised_install/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ config: "{{ sysconfdir }}/hassio.json"
machine: raspberrypi4-64
docker_repo: homeassistant
binary_docker: /usr/bin/docker
service_docker: "docker.service"
service_docker: "docker.service"
HASSIO_CONFIG: "{{ config }}"
HASSIO_APPARMOR_BINARY: "{{ prefix }}/sbin/hassio-apparmor"
SERVICE_DOCKER: "{{ service_docker }}"
BINARY_DOCKER: "{{ binary_docker }}"
11 changes: 0 additions & 11 deletions roles/supervised_install/files/NetworkManager.conf

This file was deleted.

4 changes: 0 additions & 4 deletions roles/supervised_install/files/docker_daemon.json

This file was deleted.

4 changes: 0 additions & 4 deletions roles/supervised_install/files/ha

This file was deleted.

4 changes: 0 additions & 4 deletions roles/supervised_install/files/interfaces

This file was deleted.

13 changes: 0 additions & 13 deletions roles/supervised_install/files/system-connection-default

This file was deleted.

9 changes: 8 additions & 1 deletion roles/supervised_install/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
---
- name: cleanup temp dir
file:
path: "{{ temp_config_dir.path }}"
state: absent
run_once: true
delegate_to: localhost

- name: restart docker
service:
name: docker
Expand All @@ -7,4 +14,4 @@
- name: restart networkmanager
service:
name: NetworkManager
state: restarted
state: restarted
75 changes: 66 additions & 9 deletions roles/supervised_install/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,33 @@
enabled: no
state: stopped

- name: Make temp directory for downloading Network Manager and Docker config files
tempfile:
state: directory
suffix: supervised_config
run_once: true
delegate_to: localhost
register: temp_config_dir
become: no
notify:
- cleanup temp dir

- name: Download NetworkManager and Docker config files
get_url:
url: https://raw.githubusercontent.com/home-assistant/supervised-installer/master/files/{{ config_file_name }}
dest: "{{ temp_config_dir.path }}/{{ config_file_name }}"
mode: "0440"
loop:
- NetworkManager.conf
- docker_daemon.json
- interfaces
- system-connection-default
loop_control:
loop_var: config_file_name
run_once: true
delegate_to: localhost
become: no

- name: Create Docker config directory
file:
path: /etc/docker
Expand All @@ -35,7 +62,7 @@

- name: Set up docker config file
copy:
src: docker_daemon.json
src: "{{ temp_config_dir.path }}/docker_daemon.json"
dest: /etc/docker/daemon.json
mode: '0644'
notify:
Expand All @@ -55,9 +82,9 @@
dest: "{{ networkmanager_file['target'] }}"
mode: '0644'
loop:
- source: NetworkManager.conf
- source: "{{ temp_config_dir.path }}/NetworkManager.conf"
target: /etc/NetworkManager/NetworkManager.conf
- source: system-connection-default
- source: "{{ temp_config_dir.path }}/system-connection-default"
target: /etc/NetworkManager/system-connections/default
loop_control:
loop_var: networkmanager_file
Expand All @@ -67,7 +94,7 @@

- name: Overwrite network interfaces file
copy:
src: interfaces
src: "{{ temp_config_dir.path }}/interfaces"
dest: /etc/network/interfaces
mode: '0644'
notify:
Expand Down Expand Up @@ -112,15 +139,45 @@
force_tag: yes
source: local

- name: Make temp directory for downloading Home Assistant config files
tempfile:
state: directory
suffix: supervised_config
run_once: true
delegate_to: localhost
register: temp_config_dir
become: no
notify:
- cleanup temp dir

- name: Download Home Assistant config files
get_url:
url: https://raw.githubusercontent.com/home-assistant/supervised-installer/master/files/{{ config_file_name }}
dest: "{{ temp_config_dir.path }}/{{ config_file_name }}"
mode: "0440"
become: no
loop:
- ha
- hassio-apparmor
- hassio-apparmor.service
- hassio-supervisor
- hassio-supervisor.service
loop_control:
loop_var: config_file_name
run_once: true
delegate_to: localhost

- name: Install supervisor startup script
template:
src: hassio-supervisor.j2
src: "{{ temp_config_dir.path }}/hassio-supervisor"
dest: "{{ prefix }}/sbin/hassio-supervisor"
mode: a+x
variable_start_string: "%%"
variable_end_string: "%%"

- name: Install supervisor service file
template:
src: hassio-supervisor.service.j2
src: "{{ temp_config_dir.path }}/hassio-supervisor.service"
dest: "{{ sysconfdir }}/systemd/system/hassio-supervisor.service"
mode: '0644'

Expand All @@ -137,13 +194,13 @@

- name: Install AppArmor startup script
template:
src: hassio-apparmor.j2
src: "{{ temp_config_dir.path }}/hassio-apparmor"
dest: "{{ prefix }}/sbin/hassio-apparmor"
mode: a+x

- name: Install AppArmor service file
template:
src: hassio-apparmor.service.j2
src: "{{ temp_config_dir.path }}/hassio-apparmor.service"
dest: "{{ sysconfdir }}/systemd/system/hassio-apparmor.service"
mode: '0644'

Expand All @@ -167,7 +224,7 @@

- name: Install the 'ha' cli
copy:
src: ha
src: "{{ temp_config_dir.path }}/ha"
dest: "{{ prefix }}/bin/ha"
mode: a+x

Expand Down
49 changes: 0 additions & 49 deletions roles/supervised_install/templates/hassio-apparmor.j2

This file was deleted.

12 changes: 0 additions & 12 deletions roles/supervised_install/templates/hassio-apparmor.service.j2

This file was deleted.

36 changes: 0 additions & 36 deletions roles/supervised_install/templates/hassio-supervisor.j2

This file was deleted.

15 changes: 0 additions & 15 deletions roles/supervised_install/templates/hassio-supervisor.service.j2

This file was deleted.

0 comments on commit 8734182

Please sign in to comment.