Debug School


Posted on

Write a Ansible Playbook to install a package called “git”, “wget” and run some bash script.

root@ip-172-31-87-83:~/daniel# cat git.yaml

  • name: Update web servers hosts: web


  • name: Install git in ubuntu ansible.builtin.apt: name: "git" state: latest
  • name: Install wget in ubuntu ansible.builtin.apt: name: "wget"
  • name: Copy ansible.builtin.copy: src: dest: /tmp/
  • name: Change file ownership, group and permissions ansible.builtin.file: path: /tmp/ mode: '0755'
  • name: Run a script with arguments (free form) ansible.builtin.script: /tmp/
  • name: Print return information from the previous task ansible.builtin.debug: msg: "The ansible task is completed successfully!"

The playbook result:
root@ip-172-31-87-83:~/daniel# ansible-playbook -i inventory1 git.yaml -u ubuntu --key-file=node.pem -b

PLAY [Update web servers] ******************************************************************************************************

TASK [Gathering Facts] *********************************************************************************************************
ok: []
fatal: []: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host port 22: Connection timed out", "unreachable": true}

TASK [Install git in ubuntu] ***************************************************************************************************
ok: []

TASK [Install wget in ubuntu] **************************************************************************************************
ok: []

TASK [Copy] ************************************************************************************************************
changed: []

TASK [Change file ownership, group and permissions] ****************************************************************************
ok: []

TASK [Run a script with arguments (free form)] *********************************************************************************
changed: []

TASK [Print return information from the previous task] *************************************************************************
ok: [] => {
"msg": "The ansible task is completed successfully!"

PLAY RECAP ********************************************************************************************************************* : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0 : ok=7 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

Image description

Top comments (0)