Ansible Privilege Escalation
Apr 10, 2022
When trying to connect the AWS instance and download the file, i get an error message as below.
[root@localhost ansbile_playbook]# ansible-playbook install_docker.yamlPLAY [awsnode] ********************************************************************TASK [Gathering Facts] ********************************************************************
ok: [34.229.157.247]TASK [Download the docker repo.] ********************************************************************
fatal: [34.229.157.247]: FAILED! => {"changed": false, "checksum_dest": null, "checksum_src": "d7ff809b1df9aaba3a0e3e0c68ed188e3d3ff9d9", "dest": "/etc/yum.repos.d/docker-ce.repo", "elapsed": 0, "msg": "Destination /etc/yum.repos.d is not writable", "src": "/home/ec2-user/.ansible/tmp/ansible-tmp-1649573642.0434856-1978-145705028410837/tmpesi9z8h6", "url": "https://download.docker.com/linux/rhel/docker-ce.repo"}PLAY RECAP ********************************************************************
34.229.157.247 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
The ansible.cfg was setup as below. It was disabled.
On running whoami on remote server it shows as ec2-user.
Now, update the ansible.cfg file privilege escalation.
Upon running the whoami it shows root user.
The error is gone now, and file is downloaded to path succesfully.
YAML FILE:
- hosts: awsnode
tasks:
- name: Download the docker repo.
get_url:
url: "https://download.docker.com/linux/rhel/docker-ce.repo"
dest: "/etc/yum.repos.d"