https://gist.github.com/wavedocs/f3e58c1483374590f53a1967371737ee/edit
не со всем так может работать. оказывается:
- name: Generate password for pgdbuser
shell: makepasswd --chars=12
register: "pgpasswd"
- name: Set password for pguser
shell: su - postgres -c "psql -U postgres -d postgres -c \"alter user postgres with password "{{ pgpasswd }}";\""
даёт ошибку
fatal: [ttest]: FAILED! => {
"changed": true,
"cmd": "su - postgres -c \"psql -U postgres -d postgres -c \\\"alter user postgres with password '{'stderr_lines': [], u'changed': True, u'end': u'2018-01-11 13:05:03.905902', 'failed': False, u'stdout': u'LM3pd0492hQW', u'cmd': u'makepasswd --chars=12', u'rc': 0, u'start': u'2018-01-11 13:05:03.803517', u'stderr': u'', u'delta': u'0:00:00.102385', 'stdout_lines': [u'LM3pd0492hQW']}';\\\"\"",
"delta": "0:00:00.132139",
"end": "2018-01-11 13:05:07.663898",
"invocation": {
"module_args": {
"_raw_params": "su - postgres -c \"psql -U postgres -d postgres -c \\\"alter user postgres with password '{'stderr_lines': [], u'changed': True, u'end': u'2018-01-11 13:05:03.905902', 'failed': False, u'stdout': u'LM3pd0492hQW', u'cmd': u'makepasswd --chars=12', u'rc': 0, u'start': u'2018-01-11 13:05:03.803517', u'stderr': u'', u'delta': u'0:00:00.102385', 'stdout_lines': [u'LM3pd0492hQW']}';\\\"\"",
"_uses_shell": true,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"stdin": null,
"warn": true
}
},
"msg": "non-zero return code",
"rc": 1,
"start": "2018-01-11 13:05:07.531759",
"stderr": "ERROR: unrecognized role option \"stderr_lines\"\nLINE 1: alter user postgres with password '{'stderr_lines': [], u'ch...\n ^",
"stderr_lines": [
"ERROR: unrecognized role option \"stderr_lines\"",
"LINE 1: alter user postgres with password '{'stderr_lines': [], u'ch...",
" ^"
],
"stdout": "",
"stdout_lines": []
}
:(