-
-
Save awadhwana/aaac1abe5eee919b93e1b85980c1497d to your computer and use it in GitHub Desktop.
Ansible script to install docker on EC2 instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2] | |
*instance ip address* ansible_user=ubuntu ansible_python_interpreter=/usr/bin/python3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Configure EC2 instance | |
hosts: ec2 | |
connection: ssh | |
become: yes | |
tasks: | |
- name: Update the machine | |
command: sudo apt clean && update -y | |
- name: Install basic list of packages | |
apt: | |
name: ['apt-transport-https','ca-certificates','curl','gnupg2','software-properties-common'] | |
state: present | |
update_cache: no | |
- name: Add Docker GPG apt Key | |
apt_key: url=https://download.docker.com/linux/ubuntu/gpg | |
- name: Add Docker Repository | |
apt_repository: | |
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ansible_distribution_release}} stable | |
- name: Install Docker packages | |
apt: | |
name: ['docker-ce','docker-ce-cli','containerd.io'] | |
state: present | |
#TO RUN | |
# create a file called host and add your host ip address | |
#ansible-playbook -i host docker.yml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment