Tuesday 4 February 2020

First Ansible:-Use the ping module to ping all the nodes in your inventory

Use the ping module to ping all the nodes in your inventory:

[sai@san-master-anisble ~]$cat /etc/ansible/hosts
192.161.1.10

[sai@san-master-anisble ~]$ ansible all -m ping -u root -k
SSH password:
192.161.1.10| SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}


[sai@san-master-anisble ~]$ ansible all -a "/bin/echo hello" -u root -k
SSH password:
192.161.1.11 | CHANGED | rc=0 >>
hello
[sai@san-master-anisble ~]$


If you need privilege escalation (sudo) to run a command, pass the become flags:
Case1:- noc // from noc user switched to root

[sai@san-master-anisble ~]$ ansible all -m ping -u noc --become
192.161.1.11 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}

Case 2: from noc user to switch to noc1
[sai@san-master-anisble ~]$ ansible all -m ping -u noc --become --become-user noc1
192.161.1.11 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}
[sai@san-master-anisble ~]$ 

6 comments:

  1. The main motive of the Big data cloud solutions is to spread the knowledge so that they can give more big data engineers to the world.

    ReplyDelete
  2. Great post I must say and thanks for the information. Education is definitely a sticky subject. it is still among the leading topics of our time. I appreciate your post and looking for more.
    mobile phone repair in Novi
    iphone repair in Novi
    cell phone repair in Novi
    phone repair in Novi
    tablet repair in Novi
    ipad repair in Novi
    mobile phone repair Novi
    iphone repair Novi
    cell phone repair Novi
    phone repair Novi

    ReplyDelete
  3. As claimed by Stanford Medical, It is really the one and ONLY reason this country's women get to live 10 years more and weigh 42 lbs lighter than us.

    (By the way, it is not related to genetics or some secret exercise and EVERYTHING around "HOW" they are eating.)

    P.S, What I said is "HOW", not "WHAT"...

    CLICK on this link to see if this brief questionnaire can help you find out your real weight loss potential

    ReplyDelete
  4. Awesome article. It is so detailed and well formatted that i enjoyed reading it as well as get some new information too.
    AWS Online Training
    AWS Certification Training
    AWS Certification Course Online
    AWS Training
    AWS Online Course

    ReplyDelete