MAAS Deploy - Ansible Task - Special Characters

Trying to deploy maas via ci workflow.

Down to last task but can’t figure out a few details on how it deploys with jinja and python etc.

Shell will have variables:
env_lz1_password=G@odPassword!

Task:
- name: Initialize MAAS with database URI
command: >
timeout 5m maas init region+rack --database-uri “postgres://mass_db_admin:{{ lookup(‘ansible.builtin.env’, ‘env_lz1_password’) }}@{{ inventory_hostname }}/maas_db”
register: maas_init_output
ignore_errors: yes

Two Questions:

  1. It prompts for user to add " AAS URL [default=http://10.89.135.5:5240/MAAS]: " which I need to pass as part of command but see no documentation on how to pass this

  2. Password with @ keeps catching it up. I tried postgres note on encoding https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS but this just gets different error Ex: Password set to "G%40odPassword!

Spent hours trying to pass / correct these two issues… HOping forum has shaved this yak before.

For the first point you can use maas init .. --maas-url <the url>. For the latter I recall some other people had the same issue in the past, let me try to find the links

well, you have also “!” to encode :slight_smile: something like

sudo maas init region+rack --database-uri "postgres://maas:G%40odPassword%21@localhost/maasdb" --maas-url http://<IP>:5240/MAAS

will work

Followup to close this thread out. Due to posgres you have to pass with “urlencode”

- name: Initialize MAAS with database URI
  ansible.builtin.command: >-
    maas init region+rack --database-uri "postgres://maas_db_admin:{{
      lookup("ansible.builtin.env", "env_lz1_password") | urlencode
    }}@{{ inventory_hostname }}/maas_db"
    --maas-url http://{{ inventory_hostname }}:5240/MAAS