Hello All,
Need your help on below issue.
I am trying to run kubernetes command on a remote host using ansible.
This command works when directly run on a remote host.
======> kubectl cp /etc/passwd bus-service/ssh-jumphost-6954f877bf-p5fmq:/etc/passwd_test
But when using ansible
- name: Copy commands
shell: “kubectl cp {{ item }} baas-service/{{ jumphost.stdout_lines }}:{{ item }}”
with_items: - { ‘/etc/master.passwd’ }
- { ‘/etc/passwd’ }
- { ‘/etc/group’ }
I get an error.
failed: [gngqnc014c] (item={u’/etc/master.passwd’: None}) => {
“changed”: true,
“cmd”: “kubectl cp {u’/etc/master.passwd’: None}bus-service/[u’ssh-jumphost-6954f877bf-p5fmq’, u’ssh-jumphost-6954f877bf-twg7j’, u’ssh-jumphost-6954f877bf-xrmhs’]:{u’/etc/master.passwd’: None}”,
“delta”: “0:00:00.070410”,
“end”: “2019-04-08 16:04:49.551694”,
“invocation”: {
“module_args”: {
“_raw_params”: “kubectl cp {u’/etc/master.passwd’: None}bus-service/[u’ssh-jumphost-6954f877bf-p5fmq’, u’ssh-jumphost-6954f877bf-twg7j’, u’ssh-jumphost-6954f877bf-xrmhs’]:{u’/etc/master.passwd’: None}”,
“_uses_shell”: true,
“argv”: null,
“chdir”: null,
“creates”: null,
“executable”: null,
“removes”: null,
“stdin”: null,
“warn”: true
}
},
“item”: {
“/etc/master.passwd”: null
},
“msg”: “non-zero return code”,
“rc”: 1,
“start”: “2019-04-08 16:04:49.481284”,
“stderr”: “error: Filespec must match the canonical format: [[namespace/]pod:]file/path”,
“stderr_lines”: [
“error: Filespec must match the canonical format: [[namespace/]pod:]file/path”
],
“stdout”: “”,
“stdout_lines”:
}
Can anyone help me on this issue?
Thanks