Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions tasks/advanced-resource.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
{{ '/cib/configuration/resources/' ~
'%(type)s[@id="%(id)s"]/meta_attributes[@id="%(id)s-meta_attributes"]'
| format(type = pcmk_resource.type, id = pcmk_resource.id) }}
parent_id: "{{ pcmk_resource.id }}"
# parent_id: "{{ pcmk_resource.id }}"
parent_id: "{{ pcmk_resource.id }}-meta_attributes"
with_dict: "{{ pcmk_resource.meta | default({}) }}"
loop_control:
loop_var: nvpair
label: "{{ '{' ~ nvpair.name ~ ': ' ~ nvpair.value ~ '}' }}"
# label: "{{ '{' ~ nvpair.name ~ ': ' ~ nvpair.value ~ '}' }}"
run_once: true

- name: Create resources in {{ pcmk_resource.id }}
Expand All @@ -29,9 +30,11 @@
{{ '/cib/configuration/resources/%(type)s[@id="%(id)s"]'
| format(type = pcmk_resource.type, id = pcmk_resource.id) }}
parent_id: "{{ pcmk_resource.id }}"
primitive: "{{ item.value }}"
primitive_id: "{{ item.key }}"
primitive: "{{ inner_item.value }}"
primitive_id: "{{ inner_item.key }}"
with_dict: "{{ pcmk_resource.resources }}"
run_once: true
loop_control:
loop_var: inner_item

- include_tasks: post.yml
16 changes: 16 additions & 0 deletions tasks/constraint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
- include_tasks: pre.yml

- name: Create {{ pcmk_constraint.type }} pcmk_constraint
xml:
path: "{{ pcmk_config.path }}"
Expand All @@ -13,9 +15,15 @@
{% set arg1 = pcmk_constraint['first'] %}
{% set arg2 = pcmk_constraint['then'] %}
{% endif -%}
{% if pcmk_constraint['score'] is defined %}
{{ '/cib/configuration/constraints/rsc_%(type)s[@id="%(type)s-%(arg1)s-%(arg2)s-%(score)s"]'
| format(type = pcmk_constraint.type, arg1 = arg1, arg2 = arg2, score = pcmk_constraint.score) }}
{% else %}
{{ '/cib/configuration/constraints/rsc_%(type)s[@id="%(type)s-%(arg1)s-%(arg2)s-mandatory"]'
| format(type = pcmk_constraint.type, arg1 = arg1, arg2 = arg2) }}
{% endif -%}
check_mode: false
run_once: true

- name: Set pcmk_constraint properties
xml:
Expand All @@ -31,8 +39,13 @@
{% set arg1 = pcmk_constraint['first'] %}
{% set arg2 = pcmk_constraint['then'] %}
{% endif -%}
{% if pcmk_constraint['score'] is defined %}
{{ '/cib/configuration/constraints/rsc_%(type)s[@id="%(type)s-%(arg1)s-%(arg2)s-%(score)s"]'
| format(type = pcmk_constraint.type, arg1 = arg1, arg2 = arg2, score = pcmk_constraint.score) }}
{% else %}
{{ '/cib/configuration/constraints/rsc_%(type)s[@id="%(type)s-%(arg1)s-%(arg2)s-mandatory"]'
| format(type = pcmk_constraint.type, arg1 = arg1, arg2 = arg2) }}
{% endif -%}
attribute: "{{ attr_name }}"
value: |-
{% if pcmk_constraint[attr_name] is sameas(true) %}
Expand All @@ -47,3 +60,6 @@
loop_var: attr_name
label: "{{ '{%s: %s}' | format(attr_name, pcmk_constraint[attr_name]) }}"
check_mode: false
run_once: true

- include_tasks: post.yml
6 changes: 4 additions & 2 deletions tasks/group.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
vars:
primitive_parent: '/cib/configuration/resources/group[@id="{{ pcmk_group.id }}"]'
parent_id: "{{ pcmk_group.id }}"
primitive: "{{ item.value }}"
primitive_id: "{{ item.key }}"
primitive: "{{ inner_item.value }}"
primitive_id: "{{ inner_item.key }}"
with_dict: "{{ pcmk_group.resources }}"
run_once: true
loop_control:
loop_var: inner_item

- include_tasks: post.yml
7 changes: 5 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
user:
name: "{{ pcmk_user }}"
system: true
password: "{{ pcmk_password | password_hash('sha512', ansible_hostname) }}"
# password: "{{ pcmk_password | password_hash('sha512', ansible_hostname) }}"
password: "{{ pcmk_password | password_hash('sha512') }}"

- name: Authenticate all nodes
command: >
Expand Down Expand Up @@ -45,12 +46,14 @@

- name: Start all nodes
service:
name: "{{ item }}"
name: "{{ inner_item }}"
enabled: true
state: started
loop:
- corosync
- pacemaker
loop_control:
loop_var: inner_item

- include_tasks: pre.yml

Expand Down