From bcc63465337f1589b660f069bc53103e525869c3 Mon Sep 17 00:00:00 2001 From: Tung Leo Date: Sun, 17 Mar 2024 11:19:01 +0700 Subject: [PATCH 1/2] doc: add other links --- docs/others/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 docs/others/README.md diff --git a/docs/others/README.md b/docs/others/README.md new file mode 100644 index 0000000..82f0773 --- /dev/null +++ b/docs/others/README.md @@ -0,0 +1,3 @@ +# Others + +- Install source: https://ppa-stats.sheth.io/#/?ppaName=ppa&ppaOwner=deadsnakes&packageName=python3.9 From 2fc3e44327772f7b6876c9dd314d6d0e52af9ea5 Mon Sep 17 00:00:00 2001 From: Tung Leo Date: Sun, 17 Mar 2024 11:26:37 +0700 Subject: [PATCH 2/2] doc: add terraform usage --- docs/usage/README.md | 8 ++++-- docs/usage/ansible_usage.md | 7 ++--- docs/usage/python_usage.md | 6 ++-- docs/usage/terraform_usage.md | 52 +++++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 9 deletions(-) create mode 100644 docs/usage/terraform_usage.md diff --git a/docs/usage/README.md b/docs/usage/README.md index 48d639b..f46d0eb 100644 --- a/docs/usage/README.md +++ b/docs/usage/README.md @@ -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 diff --git a/docs/usage/ansible_usage.md b/docs/usage/ansible_usage.md index 949b78e..9a8d8d8 100644 --- a/docs/usage/ansible_usage.md +++ b/docs/usage/ansible_usage.md @@ -15,7 +15,7 @@ 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 @@ -23,8 +23,7 @@ docker run --rm --network host -it devops-toolkit:latest # 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 @@ -36,7 +35,7 @@ ansible-playbook 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 ``` diff --git a/docs/usage/python_usage.md b/docs/usage/python_usage.md index 150bf80..aa3893a 100644 --- a/docs/usage/python_usage.md +++ b/docs/usage/python_usage.md @@ -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 @@ -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 @@ -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 ``` diff --git a/docs/usage/terraform_usage.md b/docs/usage/terraform_usage.md new file mode 100644 index 0000000..aa757fb --- /dev/null +++ b/docs/usage/terraform_usage.md @@ -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 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)