小编Shy*_*Jos的帖子

如何在ansible shell模块中转义特殊字符

我尝试了 bash 转义和双引号方法来转义以下 shell 命令中的特殊字符,但两者都不起作用,在 ansible playbook 中转义特殊字符的正确方法是什么?

 The offending line appears to be:

                 name: Syncing system date with htpdate failed!, Trying wget method...
                 shell: date -s "$(curl -s --head http://google.com | grep '^Date:' | sed 's/Date: //g' ) +0530"
                                                                                                ^ here

    exception type: <class 'yaml.scanner.ScannerError'>
    exception: mapping values are not allowed in this context
      in "<unicode string>", line 15, column 93
Run Code Online (Sandbox Code Playgroud)

bash yaml ansible

4
推荐指数
1
解决办法
2万
查看次数

如何在 ansible 中使用 SSH 隧道来提供对服务器的互联网访问

我们在 DC 中有几台未连接到互联网的服务器(只能通过 vpn 访问),有时我们需要使用 htpdate 更新服务器中的时间,现在我们通过创建 ssh 隧道和鱿鱼代理来完成(请参阅下面的命令) )

ssh root@192.168.30.10 -R3128:localhost:3128 
export http_proxy='http://localhost:3128' 
htpdate -da -l -P localhost:3128 3.in.pool.ntp.org 1.asia.pool.ntp.org 3.asia.pool.ntp.org
export http_proxy=' '
Run Code Online (Sandbox Code Playgroud)

如何使用 ansible 自动执行此操作?

linux ssh bash ansible

0
推荐指数
1
解决办法
5293
查看次数

标签 统计

ansible ×2

bash ×2

linux ×1

ssh ×1

yaml ×1