Commit 9344d188 authored by Florian Haas's avatar Florian Haas
Browse files

Update example playbook to support both underscores and hyphens in group names

As of Ansible 2.8, group names containing "-" (hyphen) characters are
considered invalid, and will generate a warning about
TRANSFORM_INVALID_GROUP_CHARS.

Thus, give users the ability to gradually change over their group
names by supporting both the "taiga-*" and "taiga_*" group name
patterns.

Also, update the README accordingly.
parent 3f9ca2a9
......@@ -82,8 +82,17 @@ taiga-events.example.com
## Playbooks
An example playbook is provided in `taiga.yml`. It understands the
group names `taiga-back`, `taiga-front`, and `taiga-events`, and maps
them to the roles of the same name.
group names `taiga_back`, `taiga_front`, and `taiga_events`, and maps
them to the corresponding role names.
Note that the example playbook also understands the group names
`taiga-back`, `taiga-front`, and `taiga-events`, using hyphens instead
of underscores. Running a playbook with hyphens in group names is
deprecated and will raise a warning in Ansible version 2.8 and
later. Starting with Ansible 2.10, hyphens in group names are no
longer supported — so if you use the example playbook verbatim, or use
your own playbook with hyphens in group names, please update your
inventory to correct your group names.
## Variables
......
---
# Which host runs our backend?
taiga_backend_host: "{{ hostvars[groups['taiga-back'][0]]['ansible_fqdn'] }}"
taiga_backend_host: "{{ hostvars[groups['taiga_back'][0]]['ansible_fqdn'] }}"
# Which host should run the taiga-events service?
taiga_events_host: "{{ hostvars[groups['taiga-events'][0]]['ansible_fqdn'] }}"
taiga_events_host: "{{ hostvars[groups['taiga_events'][0]]['ansible_fqdn'] }}"
# Which host should run the Taiga front end?
taiga_frontend_host: "{{ hostvars[groups['taiga-front'][0]]['ansible_fqdn'] }}"
taiga_frontend_host: "{{ hostvars[groups['taiga_front'][0]]['ansible_fqdn'] }}"
# Which user should be created on all hosts for Taiga's own purposes?
# Taiga services must not be run as root.
......
......@@ -34,9 +34,9 @@
- name: set facts identifying node roles
set_fact:
_taiga_is_back_node: "{{ ('taiga-back' in group_names) | bool | default(false) }}"
_taiga_is_front_node: "{{ ('taiga-front' in group_names) | bool | default(false) }}"
_taiga_is_events_node: "{{ ('taiga-events' in group_names) | bool | default(false) }}"
_taiga_is_back_node: "{{ ('taiga_back' in group_names) | bool | default(false) }}"
_taiga_is_front_node: "{{ ('taiga_front' in group_names) | bool | default(false) }}"
_taiga_is_events_node: "{{ ('taiga_events' in group_names) | bool | default(false) }}"
tags:
- always
......
- hosts:
- taiga-front
- taiga_front
- taiga-back
- taiga_back
- taiga-events
- taiga_events
become: false
tasks:
- name: group hosts by distribution
group_by:
key: "{{ ansible_distribution | lower }}-{{ ansible_distribution_release | lower }}"
key: "{{ ansible_distribution | lower }}_{{ ansible_distribution_release | lower }}"
changed_when: false
tags:
- always
- hosts: taiga-back
- hosts:
- taiga-back
become: false
tasks:
- name: map taiga-back to taiga_back
group_by:
key: 'taiga_back'
changed_when: false
gather_facts: false
tags:
- always
- hosts:
- taiga-front
become: false
tasks:
- name: map taiga-front to taiga_front
group_by:
key: 'taiga_front'
changed_when: false
gather_facts: false
tags:
- always
- hosts:
- taiga-events
become: false
tasks:
- name: map taiga-events to taiga_events
group_by:
key: 'taiga_events'
changed_when: false
gather_facts: false
tags:
- always
- hosts:
- taiga_back
roles:
- role: taiga-back
- hosts: taiga-events
- hosts:
- taiga_events
roles:
- role: taiga-events
- hosts: taiga-front
- hosts:
- taiga_front
roles:
- role: taiga-front
......@@ -5,13 +5,13 @@
```yaml
---
# Which host runs our backend?
taiga_backend_host: "{{ hostvars[groups['taiga-back'][0]]['ansible_fqdn'] }}"
taiga_backend_host: "{{ hostvars[groups['taiga_back'][0]]['ansible_fqdn'] }}"
# Which host should run the taiga-events service?
taiga_events_host: "{{ hostvars[groups['taiga-events'][0]]['ansible_fqdn'] }}"
taiga_events_host: "{{ hostvars[groups['taiga_events'][0]]['ansible_fqdn'] }}"
# Which host should run the Taiga front end?
taiga_frontend_host: "{{ hostvars[groups['taiga-front'][0]]['ansible_fqdn'] }}"
taiga_frontend_host: "{{ hostvars[groups['taiga_front'][0]]['ansible_fqdn'] }}"
# Which user should be created on all hosts for Taiga's own purposes?
# Taiga services must not be run as root.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment