Add reference hello_world role

This commit is contained in:
David Stephens 2022-09-09 22:24:34 +01:00
parent 1784f5663b
commit f1ce3537b9
8 changed files with 122 additions and 0 deletions

View file

@ -153,6 +153,10 @@
- heimdall
when: (heimdall_enabled | default(False))
- role: hello_world
tags:
- hello_world
- role: homeassistant
tags:
- homeassistant

View file

@ -0,0 +1,16 @@
---
hello_world_enabled: false
hello_world_available_externally: false
# directories
hello_world_data_directory: "{{ docker_home }}/hello_world"
# network
hello_world_port: "9999"
hello_world_hostname: "hello_world"
# specs
hello_world_memory: 1g
# docker
hello_world_container_name: hello_world

View file

@ -0,0 +1,15 @@
# Hello World
Homepage: <https://www.example.com/>
A few sentences here about what the application does.
## Usage
Set `hello_world_enabled: true` in your `inventories/<your_inventory>/nas.yml` file.
The Hello World web interface can be found at <http://ansible_nas_host_or_ip:9999>.
## Specific Configuration
Detail any information here about user setup steps once Ansible-NAS has started the application.

View file

@ -0,0 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
hello_world_enabled: true

View file

@ -0,0 +1,10 @@
---
- name: Stop
hosts: all
become: true
tasks:
- name: "Include {{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }} role"
include_role:
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
vars:
hello_world_enabled: false

View file

@ -0,0 +1,17 @@
---
# This is an example playbook to execute Ansible tests.
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Get container state
docker_container_info:
name: hello_world
register: result
- name: Check Hello World is running
assert:
that:
- result.container['State']['Status'] == "running"
- result.container['State']['Restarting'] == false

View file

@ -0,0 +1,17 @@
---
# This is a Hello World playbook to execute Ansible tests.
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Try and stop and remove Hello World
docker_container:
name: hello_world
state: absent
register: result
- name: Check Hello World is stopped
assert:
that:
- not result.changed

View file

@ -0,0 +1,37 @@
---
- name: Start Hello World
block:
- name: Create Hello World Directories
file:
path: "{{ item }}"
state: directory
with_items:
- "{{ hello_world_data_directory }}"
- name: Hello World Docker Container
docker_container:
name: "{{ hello_world_container_name }}"
image: crccheck/hello-world
pull: true
volumes:
- "{{ hello_world_data_directory }}:/hello_world:rw"
ports:
- "{{ hello_world_port }}:8000"
restart_policy: unless-stopped
memory: "{{ hello_world_memory }}"
labels:
traefik.enable: "{{ hello_world_available_externally | string }}"
traefik.http.routers.hello_world.rule: "Host(`{{ hello_world_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.hello_world.tls.certresolver: "letsencrypt"
traefik.http.routers.hello_world.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.hello_world.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.hello_world.loadbalancer.server.port: "4040"
when: hello_world_enabled is true
- name: Stop Hello World
block:
- name: Stop Hello World
docker_container:
name: "{{ hello_world_container_name }}"
state: absent
when: hello_world_enabled is false