gpt4 book ai didi

mysql - 使用 Ansible 任务运行 SELECT 查询

转载 作者:IT老高 更新时间:2023-10-28 23:52:21 27 4
gpt4 key购买 nike

this Ansbile 的 mysql 数据库模块列表,其中有一个用于创建数据库或创建用户等。

我想对预先存在的表运行查询,并使用该查询的结果来填充 Ansible 变量(IP 地址列表和节点类型),根据节点类型,我将在该变量上运行不同的任务.

如何在 Ansible 中完成?

最佳答案

这是大致的操作方法(但未经测试):

- name: Retrieve stuff from mysql
command: >
mysql --user=alice --password=topsecret dbname
--host=147.102.160.1 --batch --skip-column-names
--execute="SELECT stuff from stuff_table"
register: stuff
check_mode: no
changed_when: False

- name: Do something with stuff
debug: "{{ item }}"
with_items: stuff.stdout_lines

已记录 here .

关于mysql - 使用 Ansible 任务运行 SELECT 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30605950/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com