ansible - postgresql_query ansible 模块不处理命令中的反斜杠
问题描述
运行 yml 文件时,包含反斜杠的命令返回语法错误
有没有使用反斜杠运行命令的方法?
例如
- name:
hosts:
tasks:
- postgresql_query:
...
path_to_script: db.sql
db.sql
...
\c db
解决方案
根据文档postgresql_query
有一个参数db
- name: Run pgsql queries from script
postgresql_query:
db: <Name of database to connect to and run queries against>
path_to_script: <path to a SQL script on the target machine>
使用它连接到数据库,然后从 SQL 脚本运行查询。
根据您的问题描述,您似乎尝试从 SQL 脚本中连接到数据库。
推荐阅读
- java - 访问部署在 kubernetes pod 上的 Java 应用程序时获取 502 Bad Gateway (Nginx)
- node.js - 如何在 mongo 中使用 groupby 以及包含字符串的 addFields?
- sql-server - SQL Server 中的字符串日期格式问题
- django - 标记注释中的所有重复项
- javascript - 从firebase上传和检索图像
- python - 在Python中的一行中返回键,值并分配给字典
- iframe - 代码沙箱 iframe 在 Github 页面页面中不起作用
- quarkus - Quarkus 1.12.2.final 版本中的Readinessprobe 失败
- google-drive-api - DriveService.Files.Get(uid) 返回的导出链接失败并返回 HTML 400 错误
- php - 将位置过滤器添加到页面 Wordpress