问题描述:

I am trying to switch the user in a playbook.

My current playbook looks like this:

---

- hosts: server1

vars:

username: www-foobar

password: foobar

tasks:

- name: test

file: path=/home/www-foobar/testfile state=touch

su: yes

su_user: "{{ username }}"

su_pass: "{{ password }}"

This gives me the error:

TASK: [test] ******************************************************************

failed: [server1] => {"failed": true, "parsed": false}

invalid output was:

su: Authentication failure

When I am changing the line with su_pass to su_pass: foobar everything works fine:

TASK: [test] ******************************************************************

changed: [server1]


Any hints on how I can pass a variable as password?

相关阅读:
Top