To transfer a script into remote hosts and run that script into the remote machines which needs some inputs to configure

Dear Ansible friends,

I need some automation like to run a script into all remotes machines which requires some interactive input described as below:

Master server:

I need some automation like to run a script into all remotes machines which
requires some interactive input described as below:

Master server:
----------------------
/Having patch script here
/Need to Transfer the script to remote machines

The copy module can do that.

/Execute the script into remotes machines which needs configuration inputs
based on on which host it is configuring.

This can the expect module do.

Remote hosts:
-----------------------
/copied the script here
/will run the script here which had some configuration inputs as below
1. Like what is the host name that you running the script?[hostX]:<get the
host name and input host name here>

In Ansible facts you have this information, and can use this in the expect module.

2. what is host database server name?<need to find out in a file which has
a parameter db-host=hostdb> < input the host db here

To get this information, you can run the command module an register the output in a variable and then use that in the expect module.

Hi Kai,

Thanks for the reply.

Would you please provide some example based on my requirements?

And the other thing would like to know :
I have the Ansible installed in management node. And the other nodes which I am taking as remote hosts where the product software running are also having Ansible which product requires.
My question is :is that ok having Ansible installed in all remote hosts as well as management node?
Does it require same version of Ansible installed in all?

Thanks again
M I

Hi Kai,

Thanks for the reply.

Would you please provide some example based on my requirements?

This is very basic Ansible that you can learn from a book or read the Ansible docs[1].

And the other thing would like to know :
I have the Ansible installed in management node. And the other nodes which I am taking as remote hosts where the product software running are also having Ansible which product requires.
My question is :is that ok having Ansible installed in all remote hosts as well as management node?

That's not a problem, Ansible is just a program waiting to be executed by the user.

Does it require same version of Ansible installed in all?

Ansible doesn't require Ansible on the remote hosts, Ansible is agent-less and only requires SSH and Python on the remote hosts.
That said, some modules require additional Python modules on the remote node, this is documented in the documentation for each module.
And it's possible to use Ansible on entities that do not have Python.

[1] https://docs.ansible.com/

Thanks Kai for your feedback.

Now I am getting the below error:

[root@host- ansible]#
[root@host- ansible]#

[root@host- ansible]# ansible all -m ping -u root
SSH password:
SUDO password[defaults to SSH password]:
[WARNING]: * Failed to parse /etc/ansible/hosts with yaml plugin: Syntax Error while loading YAML. The error appears to have been in ‘/etc/ansible/hosts’:
line 3, column 1, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: #nfvd42ffgui 10.75.46.104 ^ here
exception type: <class ‘yaml.parser.ParserError’> exception: did not find expected in “”, line 3, column 1

[WARNING]: * Failed to parse /etc/ansible/hosts with constructed plugin: Unable to parse /etc/ansible/hosts: Syntax Error while loading YAML. The error
appears to have been in ‘/etc/ansible/hosts’: line 3, column 1, but may be elsewhere in the file depending on the exact syntax problem. The offending line
appears to be: #nfvd42ffgui 10.75.46.104 ^ here exception type: <class ‘yaml.parser.ParserError’> exception: did not find expected in
“”, line 3, column 1

[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source

[WARNING]: No inventory was parsed, only implicit localhost is available

[WARNING]: Could not match supplied host pattern, ignoring: all

[WARNING]: provided hosts list is empty, only localhost is available

[WARNING]: No hosts matched, nothing to do

I configure my /etc/ansible/hosts as below:

[FF12]
10.14.X.X
10.14.XX

and the ansible.cfg is set out with the default values.

Please suggest.

Thank you
M I C

Your error messages say your hosts file contains more info than that.
You get this error when inventory file called hosts in your case is wrong.
So if you don't share the whole file unedited we are not able to help.