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

ansible error #615

Open
ayadahm opened this issue Mar 28, 2024 · 9 comments
Open

ansible error #615

ayadahm opened this issue Mar 28, 2024 · 9 comments

Comments

@ayadahm
Copy link

ayadahm commented Mar 28, 2024

Hi Vitabaks
I got the following error When trying to run ansible-playbook deploy_pgcluster.yml.
My choice was
pgbouncer_install: false
and I did not ON any postgresql_parameters on main.yml (assuming that postgresql will be installed with default parameters from postgresql.conf)

Should I choose the minimun max_connections from the list in mail.yml ?? why ?

TASK [pre-checks : Set max_connections from vars or use default] **************************************************************************
task path: /--/--/--/--/--/postgresql_cluster/roles/pre-checks/tasks/pgbouncer.yml:5
fatal: [195.231.167.54]: FAILED! => {"msg": "Invalid data passed to 'loop', it requires a list, got this instead: . Hint: If you passed a list/dict of just one element, try adding wantlist=True to your lookup invocation or use q/query instead of lookup."}
@vitabaks
Copy link
Owner

Hi @ayadahm ! I'll check it out.

@ayadahm
Copy link
Author

ayadahm commented Mar 28, 2024

Many thanks.

There is also an error if I choose pg_stat_statements for installation from the list of extensions.

TASK [Include main variables] *************************************************************************************************************
fatal: [195.231.167.54]: FAILED! => {"ansible_facts": {}, "ansible_included_var_files": [], "changed": false, "message": "We were unable to read either as JSON nor YAML, these are the errors we got from each:\nJSON: Expecting value: line 1 column 1 (char 0)\n\nSyntax Error while loading YAML.\n  did not find expected key\n\nThe error appears to be in '/home/am/ANSIBLE/new_unilogin/patroni_from_github/postgresql_cluster/vars/main.yml': line 175, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\npostgresql_extensions: []\n  - { ext: \"pg_stat_statements\", db: \"postgres\" }\n  ^ here\nThis one looks easy to fix. It seems that there is a value started\nwith a quote, and the YAML parser is expecting to see the line ended\nwith the same kind of quote. For instance:\n\n    when: \"ok\" in result.stdout\n\nCould be written as:\n\n   when: '\"ok\" in result.stdout'\n\nOr equivalently:\n\n   when: \"'ok' in result.stdout\"\nWe could be wrong, but this one looks like it might be an issue with\nunbalanced quotes. If starting a value with a quote, make sure the\nline ends with the same set of quotes. For instance this arbitrary\nexample:\n\n    foo: \"bad\" \"wolf\"\n\nCould be written as:\n\n    foo: '\"bad\" \"wolf\"'\n"}
fatal: [195.231.167.41]: FAILED! => {"ansible_facts": {}, "ansible_included_var_files": [], "changed": false, "message": "We were unable to read either as JSON nor YAML, these are the errors we got from each:\nJSON: Expecting value: line 1 column 1 (char 0)\n\nSyntax Error while loading YAML.\n  did not find expected key\n\nThe error appears to be in '/home/am/ANSIBLE/new_unilogin/patroni_from_github/postgresql_cluster/vars/main.yml': line 175, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\npostgresql_extensions: []\n  - { ext: \"pg_stat_statements\", db: \"postgres\" }\n  ^ here\nThis one looks easy to fix. It seems that there is a value started\nwith a quote, and the YAML parser is expecting to see the line ended\nwith the same kind of quote. For instance:\n\n    when: \"ok\" in result.stdout\n\nCould be written as:\n\n   when: '\"ok\" in result.stdout'\n\nOr equivalently:\n\n   when: \"'ok' in result.stdout\"\nWe could be wrong, but this one looks like it might be an issue with\nunbalanced quotes. If starting a value with a quote, make sure the\nline ends with the same set of quotes. For instance this arbitrary\nexample:\n\n    foo: \"bad\" \"wolf\"\n\nCould be written as:\n\n    foo: '\"bad\" \"wolf\"'\n"}
fatal: [195.231.167.52]: FAILED! => {"ansible_facts": {}, "ansible_included_var_files": [], "changed": false, "message": "We were unable to read either as JSON nor YAML, these are the errors we got from each:\nJSON: Expecting value: line 1 column 1 (char 0)\n\nSyntax Error while loading YAML.\n  did not find expected key\n\nThe error appears to be in '/home/am/ANSIBLE/new_unilogin/patroni_from_github/postgresql_cluster/vars/main.yml': line 175, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\npostgresql_extensions: []\n  - { ext: \"pg_stat_statements\", db: \"postgres\" }\n  ^ here\nThis one looks easy to fix. It seems that there is a value started\nwith a quote, and the YAML parser is expecting to see the line ended\nwith the same kind of quote. For instance:\n\n    when: \"ok\" in result.stdout\n\nCould be written as:\n\n   when: '\"ok\" in result.stdout'\n\nOr equivalently:\n\n   when: \"'ok' in result.stdout\"\nWe could be wrong, but this one looks like it might be an issue with\nunbalanced quotes. If starting a value with a quote, make sure the\nline ends with the same set of quotes. For instance this arbitrary\nexample:\n\n    foo: \"bad\" \"wolf\"\n\nCould be written as:\n\n    foo: '\"bad\" \"wolf\"'\n"}

@vitabaks
Copy link
Owner

@ayadahm I have not been able to reproduce the issue with the pgbouncer pre-check.

please attach an archive of your variable files so that I can study them.

@ayadahm
Copy link
Author

ayadahm commented Mar 29, 2024

Debian.yml.txt
system.yml.txt
Here they are:
main.txt

@vitabaks
Copy link
Owner

vitabaks commented Apr 8, 2024

@ayadahm I'm sorry for the long answer.

Is this problem still relevant?

@ayadahm
Copy link
Author

ayadahm commented Apr 9, 2024

Hi yes

@SDV109
Copy link
Contributor

SDV109 commented Apr 24, 2024

@ayadahm Hi!
You made mistakes in vars/main.yml in each of the cases you described:

  1. When you commented out all the points of postgresql_parameters, you violated the syntax of yaml files, because after: you need to specify either a specific value or list it, and you get to comment out the list, but did not indicate that in your case postgresql_patameters is empty, for this you need to make the following postgresql_parameters construction
    : [] - this construction indicates that nothing is used from postgresql_parameters in this example.
    But in this case, there is an error in the algorithm, I will inform @vitabaks for correction, but I think that most likely according to the further algorithm, there would also be other errors due to the syntax.
    To summarize, you need to change main.yml like this:
postgresql_parameters: []
#  - { option: "max_connections", value: "500" }
  1. In the second case, there is a YML syntax error again, and you are specifically told:
    /home/am/ANSIBLE/new_unilogin/patroni_from_github/postgresql_cluster/vars/main.yml': line 175, column 3
    Ansible errors, of course, do not always describe exactly how to make a correction, but most often indicate the place where the correction needs to be made.
postgresql_extensions: []
  - { ext: "pg_stat_statements", db: "postgres" }

In your case, the error was that you passed as postgresql_extensions with an empty list, and after the postgresql_extensions variable, you have - {ext: "pg_stat_statements", db: "postgres"}, which ansible cannot recognize, since it is part of the list, and the variable is not open for lists.
To summarize, you need to change main.yml like this:

postgresql_extensions: 
  - { ext: "pg_stat_statements", db: "postgres" }

@vitabaks
Copy link
Owner

Thanks @SDV109

@ayadahm
Copy link
Author

ayadahm commented Apr 24, 2024

Many thanks for the correction. I will try that out. Cheers.

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

No branches or pull requests

3 participants