I am running a bash command using Ansible.
kubectl version | head -1 | awk '{print $5}'| cut -d"\"" -f2
The output is supposed to be
v1.2.0
Playbook is ::
- name: version of minion before upgrade.
command: 'kubectl version | head -1 | awk '{print $5}'| cut -d"\"" -f2'
register: version
I have also used
command: "kubectl version | head -1 | awk '{print $5}'| cut -d"\"" -f2"
But it keeps returning me the ERROR.
# ansible-playbook upgrade_k8s.yaml -i ../env/platform
ERROR! Syntax Error while loading YAML.
The error appears to have been in '/root/ejusnub/ansible/playbook/upgrade_k8s.yaml': line 40, column 50, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: version of minion before upgrade.
command: 'kubectl version | head -1 | awk '{print $5}'| cut -d"\"" -f2'
^ here
Ive even tried to escape every symbol but the same error occurs.