diff --git a/lightrix.service b/lightrix.service index 63c31e4..41b0d65 100644 --- a/lightrix.service +++ b/lightrix.service @@ -7,5 +7,5 @@ WantedBy=default.target [Service] Type=simple -ExecStart=/usr/bin/python /root/lightrix.py --room '{{lightrix_room_id}}' -c /root/.mcatrc +ExecStart=/usr/bin/python /root/lightrix/lightrix.py -r '{{lightrix_room_id}}' -c /root/.mcatrc Restart=on-failure diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..739af98 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +click==6.3 +matrix-client==0.0.2 +pytz==2015.7 +PyYAML==3.11 +requests==2.7.0 diff --git a/roles/rrix.lightrix/tasks/main.yml b/roles/rrix.lightrix/tasks/main.yml index b6979c0..de78991 100644 --- a/roles/rrix.lightrix/tasks/main.yml +++ b/roles/rrix.lightrix/tasks/main.yml @@ -1,33 +1,17 @@ --- -- name: Ensure rpi_ws281x is cloned - git: - dest: /root/rpi_ws281x/ - repo: https://github.com/jgarff/rpi_ws281x.git - update: no - -- name: Ensure rpi_ws281x is built - shell: >- - cd /root/rpi_ws281x/ && scons - -- name: Ensure the neopixel python library is built - shell: >- - cd /root/rpi_ws281x/python/ && python setup.py install - -- name: Ensure pip is installed - yum: +- include: rpi_ws281x.yml + +- name: pip is installed + apt: state: latest name: python-pip -- name: Ensure lightrix dependencies are installed +- name: pip is upgraded pip: state: latest - name: "{{item}}" - with_items: - - matrix-client - - pyyaml - - pytz - -- name: Ensure lightrix systemd service is installed + name: pip + +- name: lightrix systemd service is installed template: src: lightrix.service dest: /etc/systemd/system/lightrix.service @@ -35,16 +19,25 @@ - reload systemd - restart lightrix -- name: Ensure mcat configuration is installed +- name: mcat configuration is installed template: src: mcatrc dest: /root/.mcatrc notify: - restart lightrix -- name: Ensure lightrix is installed - copy: - src: lightrix.py - dest: /root/lightrix.py +- name: lightrix is installed + synchronize: + src: ../../../ + dest: /root/lightrix + rsync_opts: --exclude=.git notify: - restart lightrix + +- name: lightrix dependencies are installed + pip: + state: present + requirements: /root/lightrix/requirements.txt + notify: + - restart lightrix + diff --git a/roles/rrix.lightrix/tasks/rpi_ws281x.yml b/roles/rrix.lightrix/tasks/rpi_ws281x.yml new file mode 100644 index 0000000..e80d8b6 --- /dev/null +++ b/roles/rrix.lightrix/tasks/rpi_ws281x.yml @@ -0,0 +1,23 @@ +--- +- name: dependencies are installed + apt: + state: installed + name: "{{item}}" + with_items: + - swig + - python-dev + - scons + +- name: rpi_ws281x is cloned + git: + dest: /root/rpi_ws281x/ + repo: https://github.com/jgarff/rpi_ws281x.git + update: no + +- name: rpi_ws281x is built + shell: >- + cd /root/rpi_ws281x/ && scons + +- name: the neopixel python library is built + shell: >- + cd /root/rpi_ws281x/python/ && python setup.py install