feat: add labels to swarm workers
This commit is contained in:
parent
d318880600
commit
7a01bb6abf
5 changed files with 40 additions and 14 deletions
|
|
@ -134,7 +134,7 @@
|
||||||
;hash_behaviour=replace
|
;hash_behaviour=replace
|
||||||
|
|
||||||
# (pathlist) Comma separated list of Ansible inventory sources
|
# (pathlist) Comma separated list of Ansible inventory sources
|
||||||
inventory=/etc/ansible/hosts,./hosts/inventory.ini
|
inventory=/etc/ansible/hosts,./hosts/inventory.yaml
|
||||||
|
|
||||||
# (pathspec) Colon separated paths in which Ansible will search for HttpApi Plugins.
|
# (pathspec) Colon separated paths in which Ansible will search for HttpApi Plugins.
|
||||||
;httpapi_plugins=/home/aleidk/.ansible/plugins/httpapi:/usr/share/ansible/plugins/httpapi
|
;httpapi_plugins=/home/aleidk/.ansible/plugins/httpapi:/usr/share/ansible/plugins/httpapi
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
[homelab:children]
|
|
||||||
docker
|
|
||||||
|
|
||||||
[docker:children]
|
|
||||||
docker_managers
|
|
||||||
docker_workers
|
|
||||||
|
|
||||||
[docker_managers]
|
|
||||||
10.0.10.50
|
|
||||||
|
|
||||||
[docker_workers]
|
|
||||||
10.0.10.[51:52]
|
|
||||||
21
hosts/inventory.yaml
Normal file
21
hosts/inventory.yaml
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
homelab:
|
||||||
|
children:
|
||||||
|
docker:
|
||||||
|
|
||||||
|
docker:
|
||||||
|
children:
|
||||||
|
docker_managers:
|
||||||
|
docker_workers:
|
||||||
|
|
||||||
|
docker_managers:
|
||||||
|
hosts:
|
||||||
|
10.0.10.50:
|
||||||
|
|
||||||
|
docker_workers:
|
||||||
|
hosts:
|
||||||
|
10.0.10.51:
|
||||||
|
node_labels:
|
||||||
|
services_kind: projects
|
||||||
|
10.0.10.52:
|
||||||
|
node_labels:
|
||||||
|
services_kind: common
|
||||||
11
playbooks/docker/services.yaml
Normal file
11
playbooks/docker/services.yaml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
# yaml-language-server: $schema=https://raw.githubusercontent.com/ansible/ansible-lint/refs/heads/main/src/ansiblelint/schemas/playbook.json
|
||||||
|
---
|
||||||
|
- name: Deploy homelab services
|
||||||
|
hosts: 10.0.10.50
|
||||||
|
tasks:
|
||||||
|
- name: Deploy RSS Feed
|
||||||
|
community.docker.docker_stack:
|
||||||
|
state: present
|
||||||
|
name: rss
|
||||||
|
compose:
|
||||||
|
- files/docker/stack-rss.yml
|
||||||
|
|
@ -1,9 +1,15 @@
|
||||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/ansible/ansible-lint/refs/heads/main/src/ansiblelint/schemas/tasks.json
|
# yaml-language-server: $schema=https://raw.githubusercontent.com/ansible/ansible-lint/refs/heads/main/src/ansiblelint/schemas/tasks.json
|
||||||
---
|
---
|
||||||
- name: Join Docker Swarm as a worker
|
- name: Join node to swarm
|
||||||
vars:
|
vars:
|
||||||
key: "{{ groups[managers_group] | map('extract', hostvars, ['swarm_info', 'swarm_facts', 'JoinTokens', 'Worker']) | list | first }}"
|
key: "{{ groups[managers_group] | map('extract', hostvars, ['swarm_info', 'swarm_facts', 'JoinTokens', 'Worker']) | list | first }}"
|
||||||
community.docker.docker_swarm:
|
community.docker.docker_swarm:
|
||||||
state: join
|
state: join
|
||||||
join_token: "{{ key }}"
|
join_token: "{{ key }}"
|
||||||
remote_addrs: "{{ groups[managers_group] | map('extract', hostvars, ['ansible_default_ipv4', 'address']) }}"
|
remote_addrs: "{{ groups[managers_group] | map('extract', hostvars, ['ansible_default_ipv4', 'address']) }}"
|
||||||
|
|
||||||
|
- name: Set node labels
|
||||||
|
delegate_to: "{{ groups[managers_group] | first }}"
|
||||||
|
community.docker.docker_node:
|
||||||
|
hostname: "{{ ansible_hostname }}"
|
||||||
|
labels: "{{ node_labels }}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue