-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
157 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,37 @@ | ||
# ansible-ha-bridge-docker | ||
Manages ha-bridge Docker container with systemd on Raspbian and Debian OS | ||
# Ansible Role: ha-bridge-docker | ||
|
||
An Ansible role that manages ha-bridge Docker container with systemd on Raspbian and Debian OS. | ||
This role is compatible with OS version Stretch (9) and Jessie (8). | ||
|
||
## Requirements | ||
|
||
The Docker daemon should be already installed and running on the host side. | ||
I recommend using of the Ansible Galaxy role [angstwad.docker_ubuntu](https://github.com/angstwad/docker.ubuntu) to manage the Docker daemon. | ||
|
||
This role is tested with Ansible version greater equal 2.4. | ||
|
||
## Install | ||
|
||
``` | ||
$ ansible-galaxy install escalate.ha-bridge-docker | ||
``` | ||
|
||
## Role Variables | ||
|
||
Please see [defaults/main.yml](https://github.com/escalate/ansible-ha-bridge-docker/blob/master/defaults/main.yml) for a complete list of variables that can be overridden. | ||
|
||
## Dependencies | ||
|
||
None | ||
|
||
## Example Playbook | ||
|
||
``` | ||
- hosts: all | ||
roles: | ||
- escalate.ha-bridge-docker | ||
``` | ||
|
||
## License | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
|
||
ha_bridge_docker_image_version: latest | ||
ha_bridge_docker_image_name: aptalca/home-automation-bridge | ||
ha_bridge_docker_run_options: "--volume={{ha_bridge_data_path}}:/ha-bridge/data --volume={{ha_bridge_exec_path}}:/ha-bridge/exec" | ||
ha_bridge_docker_restart_container: always | ||
|
||
ha_bridge_http_port: 8080 | ||
ha_bridge_security_key: 'secret' | ||
|
||
ha_bridge_path: /opt/ha-bridge | ||
ha_bridge_data_path: "{{ha_bridge_path}}/data" | ||
ha_bridge_exec_path: "{{ha_bridge_path}}/exec" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
|
||
- name: Reload Systemd daemon | ||
systemd: | ||
daemon_reload: yes | ||
|
||
- name: Restart HA-Bridge service | ||
service: | ||
name: docker.ha-bridge | ||
state: restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
galaxy_info: | ||
author: Felix Boerner | ||
description: Manages ha-bridge Docker container with systemd on Raspbian and Debian OS | ||
company: Felix Boerner | ||
license: MIT | ||
min_ansible_version: 2.4 | ||
github_branch: master | ||
platforms: | ||
- name: Debian | ||
versions: | ||
- jessie | ||
- stretch | ||
galaxy_tags: | ||
- raspbian | ||
- raspberry | ||
- pi | ||
- raspberrypi | ||
- docker | ||
- systemd | ||
- ha | ||
- bridge | ||
- habridge | ||
dependencies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
|
||
- name: Load HA-Bridge settings for ARMv7 systems | ||
include_vars: | ||
file: armv7.yml | ||
when: ansible_architecture == 'armv7l' | ||
tags: | ||
- ha-bridge | ||
|
||
- name: Create HA-Bridge folder structure | ||
file: | ||
path: "{{item}}" | ||
state: directory | ||
owner: root | ||
group: root | ||
mode: 0755 | ||
with_items: | ||
- "{{ha_bridge_path}}" | ||
tags: | ||
- ha-bridge | ||
|
||
- name: Create HA-Bridge startup script | ||
template: | ||
src: docker.ha-bridge.service.j2 | ||
dest: /etc/systemd/system/docker.ha-bridge.service | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
notify: | ||
- Reload Systemd daemon | ||
- Restart HA-Bridge service | ||
tags: | ||
- ha-bridge | ||
|
||
- name: Force all notified handlers to run at this point | ||
meta: flush_handlers | ||
|
||
- name: Start HA-Bridge service | ||
service: | ||
name: docker.ha-bridge | ||
state: started | ||
enabled: yes | ||
tags: | ||
- ha-bridge | ||
|
||
- name: Wait for HA-Bridge service startup | ||
uri: | ||
url: "http://localhost:{{ha_bridge_http_port}}/" | ||
status_code: 200 | ||
register: result | ||
until: result.status == 200 | ||
retries: 60 | ||
delay: 5 | ||
tags: | ||
- ha-bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[Unit] | ||
Description=Docker HA-Bridge Container | ||
After=docker.service | ||
Requires=docker.service | ||
|
||
[Service] | ||
ExecStartPre=-/usr/bin/docker stop %n | ||
ExecStartPre=-/usr/bin/docker rm %n | ||
ExecStartPre=/usr/bin/docker pull {{ha_bridge_docker_image_name}}:{{ha_bridge_docker_image_version}} | ||
ExecStart=/usr/bin/docker run --init --name %n --net=host --volume=/etc/localtime:/etc/localtime:ro --volume=/etc/timezone:/etc/timezone:ro {{ha_bridge_docker_run_options}} {{ha_bridge_docker_image_name}}:{{ha_bridge_docker_image_version}} -Dserver.port={{ha_bridge_http_port}} -Djava.net.preferIPv4Stack=true -Dexec.garden=/ha-bridge/exec -Dsecurity.key={{ha_bridge_security_key}} | ||
ExecStop=/usr/bin/docker stop %n | ||
TimeoutStartSec=0 | ||
Restart={{ha_bridge_docker_restart_container}} | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
|
||
ha_bridge_docker_image_name: habridge/ha-bridge-raspberrypi3 |