ansible-collections / ansible-consul

:satellite: Ansible role for Hashicorp Consul clusters

Home Page:https://galaxy.ansible.com/ansible-community/consul/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

consul cluster forme failed

charnet1019 opened this issue · comments

ansible version: 2.12.6

inventory:

[consul_instances]
consul1 consul_node_role=bootstrap
consul2 consul_node_role=server
consul3 consul_node_role=server
consul4 consul_node_role=client

playbook

---
- hosts: consul_instances
  gather_facts: yes

  roles:
    - role: consul
      vars:
        consul_version: 1.12.2
        consul_datacenter: dc1
        consul_addresses_http: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
        consul_acl_enable: true
        consul_connect_enabled: true
        consul_install_upgrade: true
        consul_data_path: "/data/consul/data"
  tags:
    - consul

Error Info

TASK [consul : Generate ACL master token] **************************************************************************************************************************************************
task path: /home/ansible/roles/consul/tasks/acl.yml:36
skipping: [consul1] => {
    "changed": false,
    "skip_reason": "Conditional result was False"
}

TASK [consul : debug %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% bootstrap_state] ***********************************************************************************************************
task path: /home/ansible/roles/consul/tasks/acl.yml:42
skipping: [consul1] => {}
ok: [consul2] => {
    "bootstrap_state": {
        "changed": false,
        "failed": false,
        "stat": {
            "exists": false
        }
    }
}
skipping: [consul4] => {}
ok: [consul3] => {
    "bootstrap_state": {
        "changed": false,
        "failed": false,
        "stat": {
            "exists": false
        }
    }
}

TASK [consul : debug %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% consul_acl_master_token_keygen] ********************************************************************************************
task path: /home/ansible/roles/consul/tasks/acl.yml:46
skipping: [consul1] => {}
skipping: [consul4] => {}
ok: [consul2] => {
    "consul_acl_master_token_keygen": {
        "changed": false,
        "skip_reason": "Conditional result was False",
        "skipped": true
    }
}
ok: [consul3] => {
    "consul_acl_master_token_keygen": {
        "changed": false,
        "skip_reason": "Conditional result was False",
        "skipped": true
    }
}

TASK [consul : Save ACL master token] ******************************************************************************************************************************************************
task path: /home/ansible/roles/consul/tasks/acl.yml:50
skipping: [consul1] => {
    "changed": false,
    "skip_reason": "Conditional result was False"
}
fatal: [consul2]: FAILED! => {
    "msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'stdout'\n\nThe error appears to be in '/home/ansible/roles/consul/tasks/acl.yml': line 50, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n    - name: Save ACL master token\n      ^ here\n"
}
fatal: [consul3]: FAILED! => {
    "msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'stdout'\n\nThe error appears to be in '/home/ansible/roles/consul/tasks/acl.yml': line 50, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n    - name: Save ACL master token\n      ^ here\n"
}
skipping: [consul4] => {
    "changed": false,
    "skip_reason": "Conditional result was False"
}

Use the following configuration to create successfully with the same playbook.
inventory

consul1 consul_node_role=server consul_bootstrap_expect=true
consul2 consul_node_role=server consul_bootstrap_expect=true
consul3 consul_node_role=server consul_bootstrap_expect=true
consul4 consul_node_role=client

I'm experiencing the same issue

I'm experiencing the same problem. When i changed bootstrapped server to the last server on my inventory It resolved. The problem is run_once parameter. When the first host is bootstrapped in the inventory file, it skipped and run_once never let the acl token generation to the next server.

seems related to #593