diff --git a/tasks/advanced-resource.yml b/tasks/advanced-resource.yml index 31fd213..7d8e7d0 100644 --- a/tasks/advanced-resource.yml +++ b/tasks/advanced-resource.yml @@ -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 }} @@ -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 diff --git a/tasks/constraint.yml b/tasks/constraint.yml index ce40dcb..b81e413 100644 --- a/tasks/constraint.yml +++ b/tasks/constraint.yml @@ -1,4 +1,6 @@ --- +- include_tasks: pre.yml + - name: Create {{ pcmk_constraint.type }} pcmk_constraint xml: path: "{{ pcmk_config.path }}" @@ -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: @@ -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) %} @@ -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 diff --git a/tasks/group.yml b/tasks/group.yml index e09c77d..8b45c58 100644 --- a/tasks/group.yml +++ b/tasks/group.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index 9e11a82..99f2e2a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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: > @@ -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