ssh to remote node and run CLI

Hello Experts,

As you can see struggling through basic tasks will appreciate any pointers , using ansible version 2.7

cat inventory.yml
fabric01:
hosts:
build_node:
build_host: 192.168.115.101
build_username: root
build_password: 123Abdul123

root@ansibile-launch:~/ansible/tasks/add-compute# cat add-compute.yml

Without an error I can only guess, one thing i've noticed is that you
are incorrectly formatting the task

- name: return motd to registered var
  command: 'cp /root/setup_data.yaml /root/setup_data.yaml.bak'
  vars:
    ansible_user= "{{build_username}}"
    ansible_ssh_pass= "{{build_password}}"

Thans Brian ,

It fails with following

root@ansibile-launch:~/ansible/tasks/add-compute# ansible-playbook -i inventory.yml add-compute.yml -vvvv
ansible-playbook 2.7.1
config file = /etc/ansible/ansible.cfg
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
/root/ansible/tasks/add-compute/inventory.yml did not meet host_list requirements, check plugin documentation if this is unexpected
/root/ansible/tasks/add-compute/inventory.yml did not meet script requirements, check plugin documentation if this is unexpected
Parsed /root/ansible/tasks/add-compute/inventory.yml inventory source with yaml plugin
ERROR! Syntax Error while loading YAML.
mapping values are not allowed in this context

The error appears to have been in ‘/root/ansible/tasks/add-compute/add-compute.yml’: line 11, column 23, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  • name: Copy Test
    ansible_user: “{{build_username}}”
    ^ here
    We could be wrong, but this one looks like it might be an issue with
    missing quotes. Always quote template expression brackets when they
    start a value. For instance:

with_items:

  • {{ foo }}

Should be written as:

with_items:

  • “{{ foo }}”

root@ansibile-launch:~/ansible/tasks/add-compute#

root@ansibile-launch:~/ansible/tasks/add-compute# cat add-compute.yml

Hi Abdul,

You could remove the hosts from inventory.ym , else directly mention it in default hosts inventory file

Br
Vinoth