Starting all over

Hello all,
I am running an Ansible Control Node on an ALMA Linux 8.6 (RHEL variant), and have setup four Ansible Managed Nodes also running ALMA Linux 8.6.

The implementation of Ansible is via an RPM from the ALMA Linux repositories; specifically the ansible-core-2.12.2-4.el8_6.x86_64.

I added my hosts to two ini-sections inside the RPM-provided /etc/ansible/hosts file.
[webservers]
a8-ansi-w001
a8-ansi-w002

[databases]
a8-ansi-d001

a8-ansi-d002

I have distributed the SSH RSA key to all of the managed nodes from the control node, from an account that I created on both types of nodes (control and managed). The account name I created was called “admin”.

I have never written an ansible playbook successfully because I never got started, and started this all months ago, and decided to start from scratch with the latest in changes of OS and Ansible as a whole.

Anyway, The Problem, is that I executed the following command as admin on the Control Node

ansible -m ping a8-ansi-w001

And I do not see a successful response. I see the following instead:

As you can tell the host is reachable with a standard/OS ping, and accessible via SSH using the root account.

I do want to setup my environment to use the admin account to SSH over and then sudo (become?) when writing future plays/playbooks/roles.

The factory (RPM) default /etc/ansible/ansible.cfg file has nothing unhashed in it. All lines are hashed.

Any and all guidance and what I need to do with this environment to get it functional would be much appreciated.

  1. Maybe don’t run Ansible as root (just a good pattern to encourage early on)
  2. ansible -u admin -m ping a8-ansi-w001
  3. ssh admin@a8-ansi-w001 date
  4. Many distros disable ssh to the root user by default so beware of this
  5. Use -vvv or -vvvv to see more info from ansible
(attachments)

I got some authorization errpr how to troubleshoot in ansible

If I need to convert Json data to CSV can you help me with that?

(attachments)

Please keep emails on the list.

If ssh admin@a8-ansi-w001 date works, great, that removes a bundle of things.

A great tool to use for testing is RAW aka https://docs.ansible.com/ansible/latest/collections/ansible/builtin/raw_module.html

so ansible -u admin -m raw -a date a8-ansi-w001 would use the admin user and run a command without python of date on host a8-ansi-w001

(attachments)

Andrew, thanks for that set of details.

I got this:

So that is good. Am I supposed make a change in my “basically empty” ansible.cfg to accommodate using the admin account by default?

(attachments)

Warron

  1. Inventory can have ansible_user=admin (search for user on https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html)
  2. Your most recent example does not need the -u admin as it is the running user https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-remote-user
  3. Your target system a8-ansi-w001 does not have python installed or in path. You will need to install python on the target system.
(attachments)


Awesome, thanks! I will address getting Python installed on the target system, or into the PATH variable.

I addressed the setting **remote_user=**admin because that’s the user account I built for the expressed purpose of Ansible interaction. For context I used a copy of ansible.cfg.completed_disabled and unhashed the line. The file was created based on what you see below. I did not have to do anything about the Python and PATH.

Andrew,
I had generated 4 different ansbile.cfg files in a subdirectory to keep them “out of the way”

  1. ansible-config init -t all > ansible.cfg.complete_enabled

  2. ansible-config init --disabled -t all > ansible.cfg.complete_disabled

  3. ansible-config init > ansible.cfg.example_enabled

  4. ansible-confg init --disabled > ansible.cfg.example_disabled

There is no man page for ansible-config that explains the switch options “–disabled” or “-t all.” At least not from the RPMs from ALMA Linux. Is it anywhere else?

I executed the command: ansible -m ping a8-ansi-w001 without issue; however, I do get a Warning too.

The Warning that I get looks like this:

I would like to address the warning but not sure what I need to do from here. Thank you for all of your help.

(attachments)


  1. I have not used ALMA Linux but in Debian the secret sauce is https://packages.debian.org/unstable/python-is-python3 for the warning
  2. Search order for ansible.cfg is ANSIBLE_CONFIG (env), current directory, ~/.ansible.cfg, and lastly /etc/ansible/ansible.cfg
  3. ansible-config -h does not list all the options, I am reading issues to see if this is an issue for now you can read https://docs.ansible.com/ansible/latest/cli/ansible-config.html#ansible-config
(attachments)



Andrew, I truly appreciate your patience with me as I am learning quite a lot from you today.

I am aware of the order of search in which to find the ansible.cfg (and variables), so I believe I am good there.
Thank you for the Ansible Docs page about ansible-config specifically, I never saw that, probably because the documentation is so voluminous.

As for addressing the warning, I am still a little confused. I looked at the link you provided for the Debian Secret Sauce as it were.

Is the warning because Ansible is not finding a “/usr/bin/Python3.6” specifically, as opposed to the “/bin/Python3.6”? Is that the problem I am dealing with?

I set action_warnings=False in my ansible.cfg (the one I mentioned previously in this thread), so now I get this instead when I execute “ansible -m ping a8-ansi-w001”:

I still want to address the Warning, but do it properly.

(attachments)



Warron, the warning is about Python not being at /usr/bin/python

(attachments)




Got it.

(attachments)