Simple playbook with only debug works but this does not work
On Tuesday, August 29, 2023 at 12:07:35 AM UTC+5:30 Amit Kumar wrote:
> Task: checking if pip is installed or not, if not then installing pip.
>
> playbook.yml
> ---
> - name: Install pip on remote linux servers - Only Debian/ubuntu based
> will work
> hosts: ubuntu-servers
> gather_facts: false
> become: true
> vars:
> ansible_user: demouser
> tasks:
> - name: check if pip is installed or not
> stat:
> path: /usr/bin/pip
> register: pip_check
> - name: Install pip, if not installed
> apt:
> name: python3-pip
> state: present
> when: not pip_check.stat.exists
> - name: Print Message
> debug:
> msg: "pip is installed"
> handlers:
> - name: Reload bashrc
> command: "source ~/.bashrc"
> listen: "pip is installed"
>
>
> inventory.ini file
> [ubuntu-servers]
> 192.168.122.140
>
>
> Getting the following error:
> (venv)
> user@IdeaPad:~/Documents/MyFiles/dev/other_projects/learning_ansible/playbooks/install-kvm-qemu$
>
> ansible-playbook -i inventory.ini install-pip.yml
> [WARNING]: Invalid characters were found in group names but not replaced,
> use -vvvv to see details
>
> PLAY [Install pip on remote linux servers - Only Debian/ubuntu based will
> work]
> ****************************************************************************************************
>
> TASK [check if pip is installed or not]
> ********************************************************************************************************************************************
> fatal: [192.168.122.140]: UNREACHABLE! => {"changed": false, "msg":
> "Failed to connect to the host via ssh: ssh: connect to host
> 192.168.122.140 port 22: Connection refused", "unreachable": true}
>
> PLAY RECAP
> *************************************************************************************************************************************************************************
> 192.168.122.140 : ok=0 changed=0 unreachable=1
> failed=0 skipped=0 rescued=0 ignored=0
>
>
> 192.168.122.140: is the IP of the guest, and the guest is running
> Any help will be welcomed!
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/cb04510f-10d8-4c2e-90b4-4f26c841c767n%40googlegroups.com.