Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add terraform usage #115

Merged
merged 2 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/others/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Others

- Install source: https://ppa-stats.sheth.io/#/?ppaName=ppa&ppaOwner=deadsnakes&packageName=python3.9
8 changes: 6 additions & 2 deletions docs/usage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ This guide us how to use the `devops-toolkit` with serveral usecases

## Python

- Check [python_usage](./python_usage.md)
- Check [**python_usage**](./python_usage.md)

## Ansible

- Check [ansible_usage](./ansible_usage.md)
- Check [**ansible_usage**](./ansible_usage.md)

## Terraform

- Check [**terraform_usage**](./terraform_usage.md)

## Troubleshooting

Expand Down
7 changes: 3 additions & 4 deletions docs/usage/ansible_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ docker run --rm --network host -it devops-toolkit:latest
ansible-playbook samples/ansible/check_os.yml
```

## Use case 2: Clone external code to container
## Use case 2: Clone external code inside container

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

# Now run your cloned script
# Clone code
mkdir ansible_workspace
cd ansible_workspace
mkdir ansible_workspace; cd ansible_workspace
git clone https://github.com/ansible/ansible-examples.git

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

```bash
# Clone code on the host
# Given that we have code somewhere in you machine
docker run --rm -v "$(pwd)":/root/ansible_workspace --network host -it devops-toolkit:latest
# Run the ansible code as usual
```
Expand Down
6 changes: 3 additions & 3 deletions docs/usage/python_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ docker run --rm --network host -it devops-toolkit:latest
python3 samples/python/rectangle_area_calculator.py
```

## Use case 2: Clone external code to container
## Use case 2: Clone external code inside container

```bash
docker run --rm --network host -it devops-toolkit:latest
Expand All @@ -25,8 +25,7 @@ mkdir python_workspace
cd python_workspace

# Clone code
mkdir ansible_workspace
cd ansible_workspace
mkdir python_workspace; cd python_workspace
git clone https://github.com/geekcomputers/Python.git

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

```bash
# Given that we have code somewhere in you machine
docker run --rm -v "$(pwd)":/root/python_workspace --network host -it devops-toolkit:latest
# Run the python code as usual
```
Expand Down
52 changes: 52 additions & 0 deletions docs/usage/terraform_usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Use terraform in the devops-toolkit

To use the existing container isntead of creating one, use `docker exec` command instead of `docker run`

```bash
docker exec -it my_devops_toolkit /bin/bash
```

## Use case 1: Run terraform sample code provided in the container

```bash
docker run --rm --network host -it devops-toolkit:latest
# You now in the container terminal
# Navigate to Terraform sample
pushd samples/terraform/basic
# Init the terraform
terraform init
# Apply change, select 'yes' to confirm
terraform apply
# Once done, destroy the infra, select 'yes' to confirm
terraform destroy
popd
```

## Use case 2: Clone external code inside container

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

# Now run your cloned script
# Clone code
mkdir terraform_workspace; cd terraform_workspace
git clone <YOUR-REPO> terraform-examples

cd terraform-examples
# Run terraform here: init-plan-apply,...
```

## Use case 3: Mount external code to container

Clone the code to the host then mount to container

```bash
# Given that we have code somewhere in you machine
docker run --rm -v "$(pwd)":/root/terraform_workspace --network host -it devops-toolkit:latest
# Run the terraform code as usual
```

## Troubleshooting

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