Ansible - errno 101 network is unreachable

Newbie to ansible,

trying to run a playbook to one of host,

</TASK [Gathering Facts] *********************************************************
ok: [172.28.158.115]

TASK [include_role : tes.kibana] ***********************************************

TASK [doe.kibana : Add Elasticsearch GPG key.] *********************************
fatal: [172.28.158.115]: FAILED! => {“changed”: false, “msg”: “failed to fetch key at https://artifacts.elastic.co/GPG-KEY-elasticsearch , error was: Request failed: <urlopen error [Errno 101] Network is unreachable>”}

PLAY RECAP *********************************************************************
172.28.158.115 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0 >

Curl to the url works fine at host as well as at node
ssh host to node works fine

Unable to find a clue for this error

pls help

Hi

Thanks for using ansible. To answer your question more information is
needed. Could you please describe clearly all of the below:

- Which commands did you run, and what actual output did you get
(copied as plain text - not as screenshots, images, or other binary
attachments).
- What do the relevant inventory/tasks/playbooks/code/variables look like.
- The output of ‘ansible --version’

Command : ansible-playbook elk-playbook.yml
Output:
PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [172.28.158.115]

TASK [ping] ********************************************************************
ok: [172.28.158.115]

TASK [include_role : tes.elasticsearch] ****************************************

TASK [tes.elasticsearch : include_tasks] ***************************************
included: /root/.ansible/roles/tes.elasticsearch/tasks/setup-RedHat.yml for 172.28.158.115

TASK [tes.elasticsearch : Add Elasticsearch GPG key.] **************************
fatal: [172.28.158.115]: FAILED! => {“changed”: false, “msg”: “failed to fetch key at https://artifacts.elastic.co/GPG-KEY-elasticsearch , error was: Request failed: <urlopen error [Errno 101] Network is unreachable>”}

PLAY RECAP *********************************************************************
172.28.158.115 : ok=3 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

[root@localmain .ansible]#

elk-playbook has two tasks,

ping and include role tes.elasticsearch

ansible version :

[root@localmain .ansible]# ansible --version
ansible 2.9.3
config file = /etc/ansible/ansible.cfg
configured module search path = [‘/root/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.6.8 (default, Nov 21 2019, 19:31:34) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]
[root@localmain .ansible]#

Curl to the key url works on localmain(control) as well as localhost1(node)
Checked the proxy too, included proxy var in /etc/profile.d/proxy.sh

what else i missed? am not aware

Found a way through setting up

my proxy under environment: in ansible playbook,

now facing this error

FAILED! => {“changed”: false, “msg”: “Failed to download packages: Cannot download 7.6.1/elasticsearch-7.6.1-x86_64.rpm: All mirrors were tried”, “results”: }

any clue to this?

Hii

followed few help from this link https://access.redhat.com/discussions/4222851#comment-1751291 like dnf upgrade -y --releasever=8

after that on first run of

ansible-playbook -vvv --flush-cache elk-playbook.yml

Escalation succeeded
<172.28.158.118> (1, b’\r\n{“msg”: “Failed to download packages: Cannot download 7.6.1/elasticsearch-7.6.1-x86_64.rpm: All mirrors were tried”, “results”: , “failed”: true, “exception”: " File \“/tmp/ansible_dnf_payload_mmu8acfl/ansible_dnf_payload.zip/ansible/modules/packaging/os/dnf.py\”, line 1179, in ensure\n File \“/usr/lib/python3.6/site-packages/dnf/base.py\”, line 1159, in download_packages\n self._download_remote_payloads(payloads, drpm, progress, callback_total)\n File \“/usr/lib/python3.6/site-packages/dnf/base.py\”, line 1089, in _download_remote_payloads\n raise dnf.exceptions.DownloadError(errors._irrecoverable)\n", “invocation”: {“module_args”: {“name”: [“elasticsearch”], “state”: “present”, “allow_downgrade”: false, “autoremove”: false, “bugfix”: false, “disable_gpg_check”: false, “disable_plugin”: , “disablerepo”: , “download_only”: false, “enable_plugin”: , “enablerepo”: , “exclude”: , “installroot”: “/”, “install_repoquery”: true, “install_weak_deps”: true, “security”: false, “skip_broken”: false, “update_cache”: false, “update_only”: false, “validate_certs”: true, “lock_timeout”: 30, “conf_file”: null, “disable_excludes”: null, “download_dir”: null, “list”: null, “releasever”: null}}}\r\n’, b’Shared connection to 172.28.158.118 closed.\r\n’)
<172.28.158.118> Failed to connect to the host via ssh: Shared connection to 172.28.158.118 closed.
<172.28.158.118> ESTABLISH SSH CONNECTION FOR USER: None
<172.28.158.118> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/9f99d47bcf 172.28.158.118 ‘/bin/sh -c ‘"’“‘rm -f -r /root/.ansible/tmp/ansible-tmp-1584481655.4368277-75248524508419/ > /dev/null 2>&1 && sleep 0’”’"‘’
<172.28.158.118> (0, b’‘, b’')
The full traceback is:
File “/tmp/ansible_dnf_payload_mmu8acfl/ansible_dnf_payload.zip/ansible/modules/packaging/os/dnf.py”, line 1179, in ensure
File “/usr/lib/python3.6/site-packages/dnf/base.py”, line 1159, in download_packages
self._download_remote_payloads(payloads, drpm, progress, callback_total)
File “/usr/lib/python3.6/site-packages/dnf/base.py”, line 1089, in _download_remote_payloads
raise dnf.exceptions.DownloadError(errors._irrecoverable)

fatal: [172.28.158.118]: FAILED! => {
“changed”: false,
“invocation”: {
“module_args”: {
“allow_downgrade”: false,
“autoremove”: false,
“bugfix”: false,
“conf_file”: null,
“disable_excludes”: null,
“disable_gpg_check”: false,
“disable_plugin”: ,
“disablerepo”: ,
“download_dir”: null,
“download_only”: false,
“enable_plugin”: ,
“enablerepo”: ,
“exclude”: ,
“install_repoquery”: true,
“install_weak_deps”: true,
“installroot”: “/”,
“list”: null,
“lock_timeout”: 30,
“name”: [
“elasticsearch”
],
“releasever”: null,
“security”: false,
“skip_broken”: false,
“state”: “present”,
“update_cache”: false,
“update_only”: false,
“validate_certs”: true
}
},
“msg”: “Failed to download packages: Cannot download 7.6.1/elasticsearch-7.6.1-x86_64.rpm: All mirrors were tried”,
“results”:

I'm not going to waste more of my time by having information spoon fed
like this.
We're done.

anyhow newbie communication makes bad,

tried setting up a new vm tried a fresh ansible-playbook run on the vm, still getting the same error

dunno where it falls

It sounds like you require a network proxy but haven’t configured dnf to use it correctly. See https://unix.stackexchange.com/a/436562/249351

Hi Nick,

I did add the proxy to the vars in elk-playbook.yml ,

Accessing through ansible only fails

The below is my ansible section, where am doing the test
`

The actual ansible error is

`
<172.28.158.115> (1, b’\r\n{“msg”: “Failed to download packages: Cannot download 7.6.1/elasticsearch-7.6.1-x86_64.rpm: All mirrors were tried”, “results”: , “failed”: true, “exception”: " File \“/tmp/ansible_dnf_payload_w1z9yyx7/ansible_dnf_payload.zip/ansible/modules/packaging/os/dnf.py\”, line 1179, in ensure\n File \“/usr/lib/python3.6/site-packages/dnf/base.py\”, line 1149, in download_packages\n self._download_remote_payloads(payloads, drpm, progress, callback_total)\n File \“/usr/lib/python3.6/site-packages/dnf/base.py\”, line 1079, in _download_remote_payloads\n raise dnf.exceptions.DownloadError(errors._irrecoverable)\n", “invocation”: {“module_args”: {“name”: [“elasticsearch”], “state”: “present”, “allow_downgrade”: false, “autoremove”: false, “bugfix”: false, “disable_gpg_check”: false, “disable_plugin”: , “disablerepo”: , “download_only”: false, “enable_plugin”: , “enablerepo”: , “exclude”: , “installroot”: “/”, “install_repoquery”: true, “install_weak_deps”: true, “security”: false, “skip_broken”: false, “update_cache”: false, “update_only”: false, “validate_certs”: true, “lock_timeout”: 30, “conf_file”: null, “disable_excludes”: null, “download_dir”: null, “list”: null, “releasever”: null}}}\r\n’, b’Shared connection to 172.28.158.115 closed.\r\n’)
<172.28.158.115> Failed to connect to the host via ssh: Shared connection to 172.28.158.115 closed.
<172.28.158.115> ESTABLISH SSH CONNECTION FOR USER: None
<172.28.158.115> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/3242a7d1b4 172.28.158.115 ‘/bin/sh -c ‘"’“‘rm -f -r /root/.ansible/tmp/ansible-tmp-1584506598.4608717-56350147288873/ > /dev/null 2>&1 && sleep 0’”’"‘’
<172.28.158.115> (0, b’‘, b’')
The full traceback is:
File “/tmp/ansible_dnf_payload_w1z9yyx7/ansible_dnf_payload.zip/ansible/modules/packaging/os/dnf.py”, line 1179, in ensure
File “/usr/lib/python3.6/site-packages/dnf/base.py”, line 1149, in download_packages
self._download_remote_payloads(payloads, drpm, progress, callback_total)
File “/usr/lib/python3.6/site-packages/dnf/base.py”, line 1079, in _download_remote_payloads
raise dnf.exceptions.DownloadError(errors._irrecoverable)

fatal: [172.28.158.115]: FAILED! => {
“attempts”: 5,
“changed”: false,
“invocation”: {
“module_args”: {
“allow_downgrade”: false,
“autoremove”: false,
“bugfix”: false,
“conf_file”: null,
“disable_excludes”: null,
“disable_gpg_check”: false,
“disable_plugin”: ,
“disablerepo”: ,
“download_dir”: null,
“download_only”: false,
“enable_plugin”: ,
“enablerepo”: ,
“exclude”: ,
“install_repoquery”: true,
“install_weak_deps”: true,
“installroot”: “/”,
“list”: null,
“lock_timeout”: 30,
“name”: [
“elasticsearch”
],
“releasever”: null,
“security”: false,
“skip_broken”: false,
“state”: “present”,
“update_cache”: false,
“update_only”: false,
“validate_certs”: true
}
},
“msg”: “Failed to download packages: Cannot download 7.6.1/elasticsearch-7.6.1-x86_64.rpm: All mirrors were tried”,
“results”:
}

`