diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..73ee9b1 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +inventory = ./inventory diff --git a/home-assistant.yml b/home-assistant.yml index 4b38e66..6b1f044 100644 --- a/home-assistant.yml +++ b/home-assistant.yml @@ -1,10 +1,18 @@ --- -- hosts: localhost +- hosts: home-assistant tasks: + - name: Remove automations directory + file: + path: '{{ pwd_config }}/automations' + state: absent + - name: Create automations directory + file: + path: '{{ pwd_config }}/automations' + state: directory - name: Build lights automations template: src: lights.yaml.j2 - dest: configuration/automations/lights.yaml + dest: '{{ pwd_config }}/automations/lights.yaml' vars: lights: - entityId: light.bathroom_lights @@ -19,7 +27,13 @@ name: Desk Lightbar - entityId: light.table_lamp name: Table lamp + - name: Copy rest of automations + copy: + src: configuration/automations + dest: '{{ pwd_config }}' + directory_mode: yes - name: Concat scripts ansible.builtin.assemble: - src: scripts - dest: configuration/scripts.yaml + remote_src: no + src: ./scripts + dest: '{{ pwd_config }}/scripts.yaml' diff --git a/inventory/hosts.yml b/inventory/hosts.yml new file mode 100644 index 0000000..2cf12d0 --- /dev/null +++ b/inventory/hosts.yml @@ -0,0 +1,8 @@ +--- +all: + hosts: + home-assistant: + gather_facts: False + ansible_user: root + ansible_port: 2222 + pwd_config: /config \ No newline at end of file diff --git a/localhost.yml b/localhost.yml new file mode 100644 index 0000000..4b38e66 --- /dev/null +++ b/localhost.yml @@ -0,0 +1,25 @@ +--- +- hosts: localhost + tasks: + - name: Build lights automations + template: + src: lights.yaml.j2 + dest: configuration/automations/lights.yaml + vars: + lights: + - entityId: light.bathroom_lights + name: Bathroom Lights + - entityId: light.kitchen_lights + name: Kitchen Lights + - entityId: light.shower_lights + name: Shower Lights + - entityId: light.couch_lights + name: Couch Lights + - entityId: light.desk_lightbar + name: Desk Lightbar + - entityId: light.table_lamp + name: Table lamp + - name: Concat scripts + ansible.builtin.assemble: + src: scripts + dest: configuration/scripts.yaml