- name: Download and unzip httpd package hosts: all become: yes tasks: . . .

Yashesh Lele:

  • name: Download and unzip httpd package
    hosts: all
    become: yes
    tasks:
    • name: Download httpd tar.gz file
      get_url:
      url: https://www.apache.org/dist/httpd/httpd-2.4.52.tar.gz
      dest: /opt/myapp/
      register: download_result

    • name: Unarchive httpd tar.gz file
      unarchive:
      src: /opt/myapp/httpd-2.4.52.tar.gz
      dest: /opt/myapp/
      remote_src: yes
      extra_opts: “-z”
      when: download_result is succeeded

Al West:
Also please reply in thread, to be neat

Yashesh Lele:
sure

Yashesh Lele:
[root@ansiblecontroller project-1]# ansible-playbook -i inventory.txt test.yaml

PLAY [Download and unzip httpd package] *************************************************************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************************************************************************
ok: [target1]
ok: [target2]

TASK [Download httpd tar.gz file] *******************************************************************************************************************************************************************
fatal: [target2]: FAILED! => {“changed”: false, “dest”: “/opt/myapp/”, “elapsed”: 0, “gid”: 0, “group”: “root”, “mode”: “0755”, “msg”: “Request failed”, “owner”: “root”, “response”: “HTTP Error 404: Not Found”, “secontext”: “unconfined_u:object_r:usr_t:s0”, “size”: 6, “state”: “directory”, “status_code”: 404, “uid”: 0, “url”: “https://www.apache.org/dist/httpd/httpd-2.4.52.tar.gz”}
fatal: [target1]: FAILED! => {“changed”: false, “dest”: “/opt/myapp/”, “elapsed”: 0, “gid”: 0, “group”: “root”, “mode”: “0755”, “msg”: “Request failed”, “owner”: “root”, “response”: “HTTP Error 404: Not Found”, “secontext”: “unconfined_u:object_r:usr_t:s0”, “size”: 6, “state”: “directory”, “status_code”: 404, “uid”: 0, “url”: “https://www.apache.org/dist/httpd/httpd-2.4.52.tar.gz”}

PLAY RECAP ******************************************************************************************************************************************************************************************
target1 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
target2 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

Yashesh Lele:
this is the error

Al West:
Did you check the link: https://www.apache.org/dist/httpd/httpd-2.4.52.tar.gz - it 404’s for me

Yashesh Lele:
but if I install with curl its working

Yashesh Lele:
curl -O https://www.apache.org/dist/httpd/httpd-2.4.52.tar.gz

Yashesh Lele:
try this one

Al West:
no it does not work - it creates a text file, open it in your editor

Al West:
If you go here:
https://downloads.apache.org/httpd/
You can see the downloads.

Yashesh Lele:
you are simply great

Yashesh Lele:
it works

Yashesh Lele:
I just changed url path

Yashesh Lele:
:smile:

Yashesh Lele:
Thank you so much mate!!

Al West:
You are welcome