Skip to content

Commit 15f3638

Browse files
authored
Refactor Ansible playbook to use modules
1 parent 0345107 commit 15f3638

File tree

1 file changed

+42
-27
lines changed

1 file changed

+42
-27
lines changed

next-ui/ansible/playbook.yml

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,54 @@
33
become: yes
44

55
tasks:
6+
7+
- name: Update apt cache
8+
apt:
9+
update_cache: yes
10+
611
- name: Install prerequisites
7-
raw: |
8-
apt-get update
9-
apt-get install -y ca-certificates curl gnupg lsb-release
12+
apt:
13+
name:
14+
- ca-certificates
15+
- curl
16+
- gnupg
17+
- lsb-release
18+
state: present
1019

1120
- name: Add Docker GPG key
12-
raw: |
13-
mkdir -p /etc/apt/keyrings
14-
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
21+
apt_key:
22+
url: https://download.docker.com/linux/ubuntu/gpg
23+
state: present
1524

1625
- name: Add Docker repository
17-
raw: |
18-
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
19-
| tee /etc/apt/sources.list.d/docker.list > /dev/null
20-
21-
- name: Install Docker Engine
22-
raw: |
23-
apt-get update
24-
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
25-
26-
- name: Start Docker service
27-
raw: |
28-
systemctl enable docker
29-
systemctl start docker
30-
31-
- name: Add ubuntu-user to docker group
32-
raw: usermod -aG docker ubuntu
26+
apt_repository:
27+
repo: deb https://download.docker.com/linux/ubuntu jammy stable
28+
state: present
29+
30+
- name: Install Docker
31+
apt:
32+
name: docker-ce
33+
state: present
34+
update_cache: yes
35+
36+
- name: Start Docker
37+
service:
38+
name: docker
39+
state: started
40+
enabled: yes
3341

3442
- name: Pull Docker image
35-
raw: docker pull kenneth4/buygun:latest
36-
37-
- name: Stop old container if it exists
38-
raw: docker rm -f alienui || true
43+
community.docker.docker_image:
44+
name: kenneth4/alienui:latest
45+
tag: latest
46+
source: pull
3947

4048
- name: Run container
41-
raw: docker run -d -p 80:3000 --name alienui kenneth4/alienui:latest
49+
community.docker.docker_container:
50+
name: buygun
51+
image: kenneth4/alienui:latest
52+
state: started
53+
restart_policy: always
54+
published_ports:
55+
- "80:3000"
56+

0 commit comments

Comments
 (0)