Skip to content

Commit

Permalink
Implement Ansible for Project Deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
ritvik-32 committed Sep 12, 2024
1 parent 29ee4e7 commit b94c0a0
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 10 deletions.
10 changes: 5 additions & 5 deletions ansible/example_inventory.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

[all:vars]
ansible_port=22
ansible_ssh_private_key_file=" Add the path to the ssh private key example:~/.ssh/id_rsa"
ansible_ssh_private_key_file=" "
user_home="{{ ansible_env.HOME }}"
path="/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/local/go/bin:/{{ user_home }}/go/bin"
go_version=1.18.10
ssh_file_path="Specify the path to id_rsa.pub Example: .ssh/id_rsa.pub "
digital_ocean_api_token="Specify digital ocean api token"
ssh_key_name="Specify the name of your ssh key in the digital ocean account"
user="Specify the type of user you want ex: root"
ssh_file_path=""
digital_ocean_api_token=""
ssh_key_name=""
user=""



Expand Down
46 changes: 44 additions & 2 deletions ansible/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,50 @@
- name: sleep for a few seconds
command: sleep 30

- name: Install Docker
shell: sudo apt update && sudo apt install -y apt-transport-https ca-certificates curl software-properties-common && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null && sudo apt update && sudo apt install -y docker-ce docker-ce-cli containerd.io && sudo systemctl enable docker && sudo systemctl start docker
- name: Update the apt package index
apt:
update_cache: yes
become: true

- name: Install required dependencies
apt:
name:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
state: present
become: true

- name: Add Docker GPG key
ansible.builtin.shell: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
become: true

- name: Add Docker repository
ansible.builtin.shell: |
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
become: true

- name: Update apt package index after adding Docker repo
apt:
update_cache: yes
become: true

- name: Install Docker packages
apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
state: present
become: true

- name: Enable Docker service
systemd:
name: docker
enabled: yes
state: started
become: true

- name: Clone the resolute Directory
git:
Expand Down
7 changes: 4 additions & 3 deletions ansible/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
3. In the ```inventory.ini``` file make all the required changes to the following fields

```
ansible_ssh_private_key_file= "~/.ssh/id_rsa"
ssh_file_path="Specify the path to the pub key"
digital_token="Specify the digital ocean token"
ansible_ssh_private_key_file= "Specify the full path to the ssh private key Example:~/.ssh/id_rsa"
ssh_file_path="Specify the full path to id_rsa.pub Example: .ssh/id_rsa.pub"
digital_ocean_api_token="Specify the digital ocean token"
ssh_key_name="Specify the name assigned to your ssh key on digital ocean"
user="Specify the type of user you want Example: root"
```

Expand Down

0 comments on commit b94c0a0

Please sign in to comment.