Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login to Azure using Service Principal #773

Merged
merged 1 commit into from
Sep 25, 2024
Merged

Login to Azure using Service Principal #773

merged 1 commit into from
Sep 25, 2024

Conversation

vitabaks
Copy link
Owner

@vitabaks vitabaks commented Sep 25, 2024

We use Azure CLI because there is currently no Ansible module available to manage the list of IP addresses within a backend pool.

Previously, manual authentication via az login was required, which was not feasible when deploying the cluster through the Console (UI) or CI/CD. With this change, we now use a Service Principal to automate the authentication process in Azure, making the deployment fully automated and suitable for CI/CD pipelines.

Fixed:

TASK [cloud-resources : Azure: Add virtual machine IP addresses to Load Balancer backend pool] ***
failed: [localhost] (item=postgres-cluster-azure-primary-backend) => {"ansible_loop_var": "item", "changed": true, "cmd": "az network lb address-pool address add --resource-group postgres-cluster-resource-group-eastus --lb-name postgres-cluster-azure-primary --pool-name postgres-cluster-azure-primary-backend --vnet postgres-cluster-network --name address-10.0.1.4 --ip-address 10.0.1.4\n", "delta": "0:00:02.614384", "end": "2024-09-25 10:54:27.768540", "item": "primary", "msg": "non-zero return code", "rc": 1, "start": "2024-09-25 10:54:25.154156", "stderr": "ERROR: Please run 'az login' to setup account.", "stderr_lines": ["ERROR: Please run 'az login' to setup account."], "stdout": "", "stdout_lines": []}

@vitabaks vitabaks self-assigned this Sep 25, 2024
@vitabaks
Copy link
Owner Author

vitabaks commented Sep 25, 2024

Test

PLAY [Deploy PostgreSQL HA Cluster (based on "Patroni")] ***********************
...
TASK [cloud-resources : Check if Azure CLI is installed] ***********************
ok: [localhost -> 127.0.0.1]
TASK [cloud-resources : Login to Azure using Service Principal] ****************
changed: [localhost -> 127.0.0.1]
...
TASK [cloud-resources : Azure: Create or modify Load Balancer] *****************
ok: [localhost] => (item=postgres-cluster-azure-primary)
TASK [cloud-resources : Extract virtual machine private IPs] *******************
ok: [localhost] => (item=10.0.1.4)
TASK [cloud-resources : Azure: Add virtual machine IP addresses to Load Balancer backend pool] ***
changed: [localhost] => (item=postgres-cluster-azure-primary-backend)
...
  • Load Balancer has been successfully created

passed

@vitabaks vitabaks merged commit ea49eca into master Sep 25, 2024
15 checks passed
@vitabaks vitabaks deleted the az-login branch September 25, 2024 12:34
vitabaks added a commit that referenced this pull request Sep 26, 2024
Add the PG_CONSOLE_DOCKER_IMAGE variable to use the latest version of postgresql_cluster until the next version is released, which includes important features for AWS and Azure:

- #772
- #773
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant