I am not sure if this is the right stackexchange site. Please let m know, if I should ask it on other forum and which one?
I need root access to perform an action, so I tried to use become: true
- name: Modify server.properties
hosts: kafka_broker
become: true
vars:
ansible_ssh_extra_args: "-o StrictHostKeyChecking=no"
ansible_host_key_checking: false
tasks:
- name: I am confused
command: 'whoami'
register: myidentity
- name: my secret identity
debug:
msg: "{{ myidentity.stdout }}"
- name: "Add the line if it does not exist"
become: true
tags: addifnotexists
lineinfile:
path: /etc/kafka/server.properties
line: "ssl.enabled.protocols = TLSv1.2"
insertafter: EOF
state: present
backup: yes
register: addifnotexists
- debug: var=addifnotexists
One one set of servers, the user is actually root, on other set it is the account from which the script was executed.
TASK [my secret identity] *********************************************************************************************************************************************
ok: [server016] => {
"msg": "svcacct"
}
ok: [server031] => {
"msg": "svcacct"
}
ok: [server033] => {
"msg": "svcacct"
}
Other set of servers
TASK [my secret identity] *********************************************************************************************************************************************
ok: [server010] => {
"msg": "root"
}
ok: [server011] => {
"msg": "root"
}
ok: [server012] => {
"msg": "root"
}
Is this difference in the output due to any difference on the server set-up? What do I need to ask the systems admins to check or set-up
Thank you for any pointers you can provide