Ansible:将注册变量与字符串连接

Kos*_*ris 2 yaml amazon-web-services ansible

我有这个 :

  # grab the internal ip [eg 10.5.20.2]
  - name: Grab the internal ip to setup the sec group rule 
    local_action: shell /sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1 # returns the ip
    register: internal_ip # save the output of the above command in a var
  - debug: var=internal_ip.stdout
Run Code Online (Sandbox Code Playgroud)

我想在AWS安全组的入站规则中将此IP设置为单个主机IP。

像这样:10.5.20.2/32

如何将internal_ip已注册的var与字符串连接起来/32

Kos*_*ris 5

我挠了一下然后流血,但是发现了...:]

"{{ internal_ip.stdout }}/32"
Run Code Online (Sandbox Code Playgroud)