From 36eb17824ca836821823e0292ef32ddb99a8a6b2 Mon Sep 17 00:00:00 2001 From: Kristof Provost Date: Wed, 17 Apr 2024 19:47:30 +0200 Subject: [PATCH] Install libs7comm Split up the tasks into separate yaml files, for easier testing of individual tasks while we're here. --- ansible/homeassistant.yaml | 59 +++++++++++++++++++++++++++++++++++ ansible/libs7comm.yaml | 33 ++++++++++++++++++++ ansible/playbook-push.yaml | 63 +++----------------------------------- 3 files changed, 96 insertions(+), 59 deletions(-) create mode 100644 ansible/homeassistant.yaml create mode 100644 ansible/libs7comm.yaml diff --git a/ansible/homeassistant.yaml b/ansible/homeassistant.yaml new file mode 100644 index 0000000..5eddf35 --- /dev/null +++ b/ansible/homeassistant.yaml @@ -0,0 +1,59 @@ +- name: homeassistant + hosts: domoticamachines + tasks: + - name: create HA user + user: + name: "domotica" + comment: "Home Assistant" + system: yes + shell: "/sbin/nologin" + become: true + - name: create HA directory + file: + path: "/home/domotica/ha/" + state: directory + mode: 02775 + owner: "domotica" + group: "domotica" + become: true + + - name: install required python modules (pre-install) + pip: + name: "{{ item }}" + extra_args: "--upgrade" + virtualenv: "/home/domotica/ha/" + with_items: + - colorlog + become: true + - name: install defined version of Home Assistant + pip: + name: homeassistant + version: "2024.2.2" + virtualenv: "/home/domotica/ha/" + when: ha_version is defined + become: true + - name: install latest version of Home Assistant + pip: + name: homeassistant + extra_args: "--upgrade" + virtualenv: "/home/domotica/ha/" + when: ha_version is undefined + become: true + - name: install homeassistant startup script + template: + src: homeassistant + dest: "/usr/local/etc/rc.d/homeassistant" + owner: root + group: wheel + mode: 0755 + become: true + - name: start home assistant + community.general.sysrc: + name: homeassistant_enable + value: "YES" + become: true + - name: Start homeassistant + ansible.builtin.service: + name: homeassistant + state: started + become: true diff --git a/ansible/libs7comm.yaml b/ansible/libs7comm.yaml new file mode 100644 index 0000000..224381d --- /dev/null +++ b/ansible/libs7comm.yaml @@ -0,0 +1,33 @@ +- name: Install libs7comm.so + hosts: domoticamachines + tasks: + - name: Install git + community.general.pkgng: + name: git + state: present + become: true + - name: Install gmake + community.general.pkgng: + name: gmake + state: present + become: true + - name: Git checkout + ansible.builtin.git: + repo: 'https://github.com/kprovost/libs7comm.git' + dest: /home/kp/libs7comm + - name: Build libs7comm + ansible.builtin.command: + cmd: /usr/local/bin/gmake -C /home/kp/libs7comm/src CC=cc LD=cc CXX=c++ s7get/s7get + creates: /home/kp/libs7comm/src/s7get/s7get + - name: Install libs7comm.so.0.0.1 + ansible.builtin.copy: + src: /home/kp/libs7comm/src/lib/libs7comm.so.0.0.1 + dest: /usr/local/lib/libs7comm.so.0.0.1 + remote_src: yes + become: true + - name: Install libs7comm.so.0.0 + ansible.builtin.file: + src: libs7comm.so.0.0.1 + dest: /usr/local/lib/libs7comm.so.0.0 + state: link + become: true diff --git a/ansible/playbook-push.yaml b/ansible/playbook-push.yaml index aa97b9e..49ff304 100644 --- a/ansible/playbook-push.yaml +++ b/ansible/playbook-push.yaml @@ -1,59 +1,4 @@ -- name: Install packages - hosts: domoticamachines - tasks: - - name: create HA user - user: - name: "domotica" - comment: "Home Assistant" - system: yes - shell: "/sbin/nologin" - become: true - - name: create HA directory - file: - path: "/home/domotica/ha/" - state: directory - mode: 02775 - owner: "domotica" - group: "domotica" - become: true - - - name: install required python modules (pre-install) - pip: - name: "{{ item }}" - extra_args: "--upgrade" - virtualenv: "/home/domotica/ha/" - with_items: - - colorlog - become: true - - name: install defined version of Home Assistant - pip: - name: homeassistant - version: "2024.2.2" - virtualenv: "/home/domotica/ha/" - when: ha_version is defined - become: true - - name: install latest version of Home Assistant - pip: - name: homeassistant - extra_args: "--upgrade" - virtualenv: "/home/domotica/ha/" - when: ha_version is undefined - become: true - - name: install homeassistant startup script - template: - src: homeassistant - dest: "/usr/local/etc/rc.d/homeassistant" - owner: root - group: wheel - mode: 0755 - become: true - - name: start home assistant - community.general.sysrc: - name: homeassistant_enable - value: "YES" - become: true - - name: Start homeassistant - ansible.builtin.service: - name: homeassistant - state: started - become: true +- name: homeassistant + import_playbook: homeassistant.yaml +- name: libs7comm + import_playbook: libs7comm.yaml -- 2.51.0