-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
956e3e1
commit b56daef
Showing
8 changed files
with
135 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Prepare common tasks | ||
|
||
- name: Update apt cache | ||
apt: | ||
update_cache: yes | ||
cache_valid_time: 3600 | ||
|
||
- name: Install required system packages | ||
apt: | ||
name: "{{ packages }}" | ||
vars: | ||
packages: | ||
- ca-certificates | ||
- curl | ||
- gnupg | ||
- make | ||
- rsync | ||
|
||
- name: Ensure ansible_user owns the deploy folder | ||
file: | ||
path: /srv | ||
owner: "{{ ansible_user }}" | ||
state: directory | ||
recurse: yes | ||
|
||
- name: Update hostname | ||
hostname: | ||
name: "{{ inventory_hostname }}" | ||
|
||
- name: Update PS1 to show full hostname | ||
replace: | ||
path: /home/{{ ansible_user }}/.bashrc | ||
regexp: '\\u@\\h' | ||
replace: '\\u@\\H' | ||
backup: yes |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Install Docker and Docker Compose | ||
|
||
- name: Add Docker’s official GPG key | ||
apt_key: | ||
url: https://download.docker.com/linux/debian/gpg | ||
state: present | ||
|
||
- name: Set up the stable repository | ||
apt_repository: | ||
repo: "deb [arch=arm64] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable" | ||
state: present | ||
|
||
- name: Install Docker Engine | ||
apt: | ||
name: docker-ce | ||
state: latest | ||
|
||
- name: Add current user to the docker group | ||
user: | ||
name: "{{ ansible_user }}" | ||
groups: docker | ||
append: yes | ||
|
||
- name: Ensure Docker service is running | ||
service: | ||
name: docker | ||
state: started | ||
enabled: yes | ||
|
||
- name: Verify Docker installation | ||
command: docker --version | ||
register: docker_version | ||
changed_when: false | ||
|
||
- name: Output Docker version | ||
debug: | ||
var: docker_version.stdout | ||
|
||
- name: Verify Docker Compose plugin installation | ||
command: docker compose version | ||
register: compose_version | ||
changed_when: false | ||
|
||
- name: Output Docker Compose plugin version | ||
debug: | ||
var: compose_version.stdout |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Setup swap | ||
|
||
- name: Check if swap is already enabled | ||
shell: swapon --show | grep -q "^" | ||
register: swap_exists | ||
changed_when: false | ||
ignore_errors: true | ||
|
||
- name: Create swap file | ||
command: fallocate -l 1G /swapfile | ||
when: swap_exists.rc != 0 | ||
become: yes | ||
|
||
- name: Set swap file permissions | ||
file: | ||
path: /swapfile | ||
mode: '0600' | ||
when: swap_exists.rc != 0 | ||
become: yes | ||
|
||
- name: Set up swap space | ||
command: mkswap /swapfile | ||
when: swap_exists.rc != 0 | ||
become: yes | ||
|
||
- name: Enable swap | ||
command: swapon /swapfile | ||
when: swap_exists.rc != 0 | ||
become: yes | ||
|
||
- name: Add swap to fstab | ||
blockinfile: | ||
path: /etc/fstab | ||
block: "/swapfile none swap sw 0 0" | ||
marker: "# {mark} ANSIBLE MANAGED BLOCK" | ||
when: swap_exists.rc != 0 | ||
become: yes |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
- name: Install required packages and settings on Debian/Ubuntu Server | ||
hosts: | ||
- development2 | ||
become: yes | ||
tasks: | ||
- import_tasks: ./partials/common-tasks.yml | ||
- import_tasks: ./partials/install-docker.yml | ||
- import_tasks: ./partials/setup-swap.yml |
This file contains 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