如何从Ansible获取postgresql

编程入门 行业动态 更新时间:2024-10-16 00:17:02
本文介绍了如何从Ansible获取postgresql_query结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试打印由Ansible运行的PostgreSQL查询的输出.不幸的是,我不确定如何获取返回值.

I'm trying to print the output of PostgreSQL query that is run by Ansible. Unfortunately I'm not sure how to get ahold of the return value.

- name: Get specific tables postgresql_query: db: "{{ database_name }}" login_host: "{{ my_host }}" login_user: "{{ my_user }}" login_password: "{{ my_password }}" query: SELECT * FROM pg_tables t WHERE t.tableowner = current_user

谷歌搜索只是说要使用 register:,但是PostgreSQL ansible模块没有 register 参数:

Googling just says to use register:, but the PostgreSQL ansible module does not have a register param:

fatal: [xx.xxx.xx.xx]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (postgresql_query) module: register Supported parameters include: ca_cert, db, login_host, login_password, login_unix_socket, login_user, named_args, path_to_script, port, positional_args, query, session_role, ssl_mode"}

Ansible docs 列出的返回值此模块,但没有有关如何使用它们的示例,我搜索的所有内容都可以直接回到 register: .

The Ansible docs list return values for this module but there are no examples on how to use them, and everything I search for leads right back to register:.

推荐答案

听起来像你的声音很近,但是 register 的缩进错误.这是任务本身的参数,而不是postgresql模块.

Sounds like you are very close, but have register at the wrong indentation. It's a parameter of the task itself, not the postgresql module.

尝试:

- name: Get specific tables postgresql_query: db: "{{ database_name }}" login_host: "{{ my_host }}" login_user: "{{ my_user }}" login_password: "{{ my_password }}" query: SELECT * FROM pg_tables t WHERE t.tableowner = current_user register: result - debug: var: result

更多推荐

如何从Ansible获取postgresql

本文发布于:2023-10-28 03:54:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1535438.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Ansible   postgresql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!