Skip to content

Commit 623b162

Browse files
authored
doc: add terraform usage (#115)
2 parents 1db320d + 2fc3e44 commit 623b162

File tree

5 files changed

+67
-9
lines changed

5 files changed

+67
-9
lines changed

docs/others/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Others
2+
3+
- Install source: https://ppa-stats.sheth.io/#/?ppaName=ppa&ppaOwner=deadsnakes&packageName=python3.9

docs/usage/README.md

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

55
## Python
66

7-
- Check [python_usage](./python_usage.md)
7+
- Check [**python_usage**](./python_usage.md)
88

99
## Ansible
1010

11-
- Check [ansible_usage](./ansible_usage.md)
11+
- Check [**ansible_usage**](./ansible_usage.md)
12+
13+
## Terraform
14+
15+
- Check [**terraform_usage**](./terraform_usage.md)
1216

1317
## Troubleshooting
1418

docs/usage/ansible_usage.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@ docker run --rm --network host -it devops-toolkit:latest
1515
ansible-playbook samples/ansible/check_os.yml
1616
```
1717

18-
## Use case 2: Clone external code to container
18+
## Use case 2: Clone external code inside container
1919

2020
```bash
2121
docker run --rm --network host -it devops-toolkit:latest
2222
# You now in the container terminal
2323

2424
# Now run your cloned script
2525
# Clone code
26-
mkdir ansible_workspace
27-
cd ansible_workspace
26+
mkdir ansible_workspace; cd ansible_workspace
2827
git clone https://github.com/ansible/ansible-examples.git
2928

3029
cd ansible-examples
@@ -36,7 +35,7 @@ ansible-playbook <YOUR_PLAYBOOK_CMD>
3635
Clone the code to the host then mount to container
3736

3837
```bash
39-
# Clone code on the host
38+
# Given that we have code somewhere in you machine
4039
docker run --rm -v "$(pwd)":/root/ansible_workspace --network host -it devops-toolkit:latest
4140
# Run the ansible code as usual
4241
```

docs/usage/python_usage.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ docker run --rm --network host -it devops-toolkit:latest
1515
python3 samples/python/rectangle_area_calculator.py
1616
```
1717

18-
## Use case 2: Clone external code to container
18+
## Use case 2: Clone external code inside container
1919

2020
```bash
2121
docker run --rm --network host -it devops-toolkit:latest
@@ -25,8 +25,7 @@ mkdir python_workspace
2525
cd python_workspace
2626

2727
# Clone code
28-
mkdir ansible_workspace
29-
cd ansible_workspace
28+
mkdir python_workspace; cd python_workspace
3029
git clone https://github.com/geekcomputers/Python.git
3130

3231
# Now run your cloned script
@@ -39,6 +38,7 @@ python3 Day_of_week.py
3938
Clone the code to the host then mount to container
4039

4140
```bash
41+
# Given that we have code somewhere in you machine
4242
docker run --rm -v "$(pwd)":/root/python_workspace --network host -it devops-toolkit:latest
4343
# Run the python code as usual
4444
```

docs/usage/terraform_usage.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Use terraform 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 terraform sample code provided in the container
10+
11+
```bash
12+
docker run --rm --network host -it devops-toolkit:latest
13+
# You now in the container terminal
14+
# Navigate to Terraform sample
15+
pushd samples/terraform/basic
16+
# Init the terraform
17+
terraform init
18+
# Apply change, select 'yes' to confirm
19+
terraform apply
20+
# Once done, destroy the infra, select 'yes' to confirm
21+
terraform destroy
22+
popd
23+
```
24+
25+
## Use case 2: Clone external code inside container
26+
27+
```bash
28+
docker run --rm --network host -it devops-toolkit:latest
29+
# You now in the container terminal
30+
31+
# Now run your cloned script
32+
# Clone code
33+
mkdir terraform_workspace; cd terraform_workspace
34+
git clone <YOUR-REPO> terraform-examples
35+
36+
cd terraform-examples
37+
# Run terraform here: init-plan-apply,...
38+
```
39+
40+
## Use case 3: Mount external code to container
41+
42+
Clone the code to the host then mount to container
43+
44+
```bash
45+
# Given that we have code somewhere in you machine
46+
docker run --rm -v "$(pwd)":/root/terraform_workspace --network host -it devops-toolkit:latest
47+
# Run the terraform code as usual
48+
```
49+
50+
## Troubleshooting
51+
52+
- For any issues, check [this reference](../troubleshooting/TROUBLESHOOTING.md)

0 commit comments

Comments
 (0)