- name: Add targeted machine to domain
become_user: <local user>
expect:
command: /bin/bash -c "/usr/sbin/realm join --user={{ prompted_user }}@domain.com domain.com
responses:
Password for .*: "{{ prompted_pass }}"
fatal: [<host-ip>]: FAILED => {
"changed":true,
"cmd": "bin/bash -c \"/usr/sbin/realm join [email protected] domain.com\"",
"delta": "0:00:00.459430"
"end"; "<date_time>"
"invocation" : {
"module_args": {
"chdir": null,
"command": "bin/bash -c \"/usr/sbin/realm join [email protected] domain.com\"",
"creates": null,
"echo": false
"removes": null,
"responses" : {
"Password for .*": "<prompted_pass>"
},
"timeout": 30
}
},
"msg": "non-zero return code",
"rc": 1,
"start": "<data_time>"
"stdout": "Password for [email protected]: \r\nrealm: Couldn't join realm: Not authorized to perform this action:,
"stdout_lines": [
"Password for [email protected]: ",
"realm: Couldn't join realm: Not authorized to perform this action"
]
}
The top is the task and the bottom is the output. I don't know why its not passing the password or, if it is I don't know why its not running sudo when I do these actions traditionally without ansible it works just fine. Defiantly need help.
Thank you
Assuming the prompted_user and prompted_pass variables are filled elsewhere, it looks like
become: yes
is missing, andbecome_user:
should beroot
.Note: if you have
become_user: root
andbecome_method: sudo
in the/etc/ansible/ansible.cfg
or in anansible.config
file within your role, or you have applied them at the commandline, or at the playbook or role level, you do not need to apply these at the task level.