Skip to content

Commit 1c48b2d

Browse files
authored
doc: ansible user guide (#112)
2 parents 65bd316 + cdc769c commit 1c48b2d

File tree

5 files changed

+70
-13
lines changed

5 files changed

+70
-13
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ docker run --network host --rm devops-toolkit:latest samples/run_sample.sh
119119
## User guide
120120

121121
- [DevOps toolkit user guide](./docs/usage/)
122+
- [Troubleshooting](./docs/troubleshooting/)
122123

123124
## The DevOps Toolkit Core
124125

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# Most common error
22

3+
#### docker-on-wsl2-very-slow
4+
35
- <https://stackoverflow.com/questions/62154016/docker-on-wsl2-very-slow>
46

5-
- exec /usr/local/bin/kubectl: exec format error
6-
See: <https://stackoverflow.com/questions/73398714/docker-fails-when-building-on-m1-macs-exec-usr-local-bin-docker-entrypoint-sh>
7+
#### exec /usr/local/bin/kubectl: exec format error
8+
9+
- See: <https://stackoverflow.com/questions/73398714/docker-fails-when-building-on-m1-macs-exec-usr-local-bin-docker-entrypoint-sh>
10+
Check architecure: dpkg --print-architecture
711

8-
- Check architecure: dpkg --print-architecture
12+
#### docker: Error response from daemon: Conflict. The container name "/my_devops_toolkit" is already in use by container
913

10-
- docker: Error response from daemon: Conflict. The container name "/my_devops_toolkit" is already in use by container
14+
- Fix by using anotehr name or delete the current container

docs/usage/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ This guide us how to use the `devops-toolkit` with serveral usecases
66

77
- Check [python_usage](./python_usage.md)
88

9+
## Ansible
10+
11+
- Check [ansible_usage](./ansible_usage.md)
12+
913
## Troubleshooting
1014

1115
- For any issues, check [this document](../troubleshooting/TROUBLESHOOTING.md)

docs/usage/ansible_usage.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Use ansible in the devops-toolkit
2+
3+
To use the existing container isntead of creating one, use `docker exec` command instead of `docker run`
4+
5+
```bash
6+
docker exec -it my_devops_toolkit /bin/bash
7+
```
8+
9+
## Use case 1: Run Ansible sample code provided in the container
10+
11+
```bash
12+
docker run --rm --network host -it devops-toolkit:latest
13+
14+
# You now in the container terminal
15+
ansible-playbook samples/ansible/check_os.yml
16+
```
17+
18+
## Use case 2: Clone external code to container
19+
20+
```bash
21+
docker run --rm --network host -it devops-toolkit:latest
22+
# You now in the container terminal
23+
24+
# Now run your cloned script
25+
cd ansible-examples
26+
ansible-playbook <YOUR_PLAYBOOK_CMD>
27+
```
28+
29+
## Use case 3: Mount external code to container
30+
31+
Clone the code to the host then mount to container
32+
33+
```bash
34+
# Clone code on the host
35+
docker run --rm -v "$(pwd)":/root/ansible_workspace --network host -it devops-toolkit:latest
36+
# Run the ansible code as usual
37+
```
38+
39+
## Troubleshooting
40+
41+
- For any issues, check [this reference](../troubleshooting/TROUBLESHOOTING.md)

docs/usage/python_usage.md

+16-9
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,46 @@
33
To use the existing container isntead of creating one, use `docker exec` command instead of `docker run`
44

55
```bash
6+
# Given that we have 'my_devops_toolkit' start before
67
docker exec -it my_devops_toolkit /bin/bash
78
```
89

9-
## Run python sample code provided in the container
10+
## Use case 1: Run python sample code provided in the container
1011

1112
```bash
12-
docker run --name my_devops_toolkit --network host -it devops-toolkit:latest
13-
# You now in the container terminal
13+
docker run --rm --network host -it devops-toolkit:latest
14+
# You now in the container terminal
1415
python3 samples/python/rectangle_area_calculator.py
1516
```
1617

17-
## Clone external code to container
18+
## Use case 2: Clone external code to container
1819

1920
```bash
20-
docker run --name my_devops_toolkit --network host -it devops-toolkit:latest
21+
docker run --rm --network host -it devops-toolkit:latest
2122
# You now in the container terminal
22-
2323
# Clone code
2424
mkdir python_workspace
2525
cd python_workspace
26+
27+
# Clone code
28+
mkdir ansible_workspace
29+
cd ansible_workspace
2630
git clone https://github.com/geekcomputers/Python.git
2731

2832
# Now run your cloned script
2933
cd Python
3034
python3 Day_of_week.py
3135
```
3236

33-
## Mount external code to container
37+
## Use case 3: Mount external code to container
3438

3539
Clone the code to the host then mount to container
3640

3741
```bash
38-
# Clone code on the host
39-
docker run --name my_devops_toolkit -v "$(pwd)":/root/python_workspace --network host -it devops-toolkit:latest
42+
docker run --rm -v "$(pwd)":/root/python_workspace --network host -it devops-toolkit:latest
4043
# Run the python code as usual
4144
```
45+
46+
## Troubleshooting
47+
48+
- For any issues, check [this reference](../troubleshooting/TROUBLESHOOTING.md)

0 commit comments

Comments
 (0)