vitabaks / postgresql_cluster

PostgreSQL High-Availability Cluster (based on Patroni). Automating with Ansible.
https://postgresql-cluster.org
MIT License
1.62k stars 407 forks source link

Consul role uses inside is not support consul versions higher 1.11.x since were introduced breaking changes in config file from consul side #785

Open garry-t opened 1 week ago

garry-t commented 1 week ago

Need to update role according to master branch of role https://github.com/ansible-collections/ansible-consul. Fun starts from version 1.12.x

See https://developer.hashicorp.com/consul/docs/upgrading/upgrade-specific#consul-1-12-x See https://developer.hashicorp.com/consul/docs/upgrading/upgrade-specific#consul-1-13-x See https://developer.hashicorp.com/consul/docs/upgrading/upgrade-specific#consul-1-14-x

tls, addresses ,ports - are affected by these changes master branch of consul ansible role already has it theirs configs

vitabaks commented 1 week ago

Now we are installing the latest available version of Consul from the hashicorp repository (now it's v1.19) and tests show that it works.

  TASK [consul : Looking up latest version of Consul] ****************************
  ok: [10.172.0.21]
  ok: [10.172.0.20]
  ok: [10.172.0.22]

...

  TASK [consul : Add hashicorp repository] ***************************************
  changed: [10.172.0.22]
  changed: [10.172.0.21]
  changed: [10.172.0.20]

  TASK [consul : Install consul package] *****************************************
  changed: [10.172.0.21]
  changed: [10.172.0.20]
  changed: [10.172.0.22]
...

  TASK [consul : Start Consul] ***************************************************
  changed: [10.172.0.21]
  changed: [10.172.0.20]
  changed: [10.172.0.22]

  TASK [consul : Check Consul HTTP API (via TCP socket)] *************************
  ok: [10.172.0.21]
  ok: [10.172.0.20]
  ok: [10.172.0.22]

...

  TASK [deploy-finish : Postgres Cluster info] ***********************************
  ok: [10.172.0.20] => {
      "msg": [
          "+ Cluster: postgres-cluster (7423961020152107459) --+-----------+-----------------+------------------------------------+-----------------+",
          "| Member   | Host        | Role    | State     | TL | Lag in MB | Pending restart | Pending restart reason             | Tags            |",
          "+----------+-------------+---------+-----------+----+-----------+-----------------+------------------------------------+-----------------+",
          "| pgnode01 | 10.172.0.20 | Leader  | running   |  2 |           | *               | max_prepared_transactions: 2000->0 | datacenter: dc1 |",
          "|          |             |         |           |    |           |                 |                                    | key1: value1    |",
          "+----------+-------------+---------+-----------+----+-----------+-----------------+------------------------------------+-----------------+",
          "| pgnode02 | 10.172.0.21 | Replica | streaming |  2 |         0 | *               | max_prepared_transactions: 2000->0 | datacenter: dc1 |",
          "|          |             |         |           |    |           |                 |                                    | key1: value1    |",
          "+----------+-------------+---------+-----------+----+-----------+-----------------+------------------------------------+-----------------+",
          "| pgnode03 | 10.172.0.22 | Replica | streaming |  2 |         0 | *               | max_prepared_transactions: 2000->0 | datacenter: dc1 |",
          "|          |             |         |           |    |           |                 |                                    | key1: value1    |",
          "+----------+-------------+---------+-----------+----+-----------+-----------------+------------------------------------+-----------------+"
      ]
  }

  TASK [deploy-finish : Connection info] *****************************************
  ok: [10.172.0.20] => {
      "msg": {
          "address": {
              "primary": "master.postgres-cluster.service.consul",
              "replica": "replica.postgres-cluster.service.consul"
          },
          "password": "tUnMwGfxt3eZzg15C1VGr3MGqdUqxXnG",
          "port": "6432",
          "superuser": "postgres"
      }
  }

I don't use Consul in production (I use etcd), so it's hard for me to say how important these configuration changes really are. Could you take on this task and offer a PR?

garry-t commented 1 week ago

I need to check also from my side, since I use this role in customised way. I'll get back a bit later.

garry-t commented 1 week ago

yes, and I missed your latest release of this role, so this issue in not relevant since you already points to latest version. But what I'll do it will test this latest role against my consul cluster.

garry-t commented 1 week ago

Ok, I've checked role config you have here, config.json is not ready for consul higher version than 1.12.x To fix problem need to use master version of consul role, but master branch has at least 3 opened issue which will potentially impact on cluster deployment.
As example https://github.com/ansible-collections/ansible-consul/blob/a342eefd6308d92c346324bdcd6506dcf16cd549/templates/config.json.j2#L55-L57

So I'll test and will provide some fixes, after I'll finish with consul cluster upgrade