Skip to content

Commit

Permalink
doc: ansible user guide.v3
Browse files Browse the repository at this point in the history
  • Loading branch information
tungbq committed Mar 16, 2024
1 parent 9140a51 commit cdc769c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
18 changes: 7 additions & 11 deletions docs/usage/ansible_usage.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Use python in the devops-toolkit
# Use ansible 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 python sample code provided in the container
## Use case 1: Run Ansible sample code provided in the container

```bash
docker run --rm --network host -it devops-toolkit:latest

# You now in the container terminal
python3 samples/python/rectangle_area_calculator.py
ansible-playbook samples/ansible/check_os.yml
```

## Use case 2: Clone external code to container
Expand All @@ -20,14 +21,9 @@ python3 samples/python/rectangle_area_calculator.py
docker run --rm --network host -it devops-toolkit:latest
# You now in the container terminal

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

# Now run your cloned script
cd Python
python3 Day_of_week.py
cd ansible-examples
ansible-playbook <YOUR_PLAYBOOK_CMD>
```

## Use case 3: Mount external code to container
Expand All @@ -37,7 +33,7 @@ Clone the code to the host then mount to container
```bash
# Clone code on the host
docker run --rm -v "$(pwd)":/root/ansible_workspace --network host -it devops-toolkit:latest
# Run the python code as usual
# Run the ansible code as usual
```

## Troubleshooting
Expand Down
17 changes: 10 additions & 7 deletions docs/usage/python_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,31 @@ To use the existing container isntead of creating one, use `docker exec` command
docker exec -it my_devops_toolkit /bin/bash
```

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

```bash
docker run --rm --network host -it devops-toolkit:latest
# You now in the container terminal
ansible-playbook samples/ansible/check_os.yml
# You now in the container terminal
python3 samples/python/rectangle_area_calculator.py
```

## Use case 2: Clone external code to container

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

# Clone code
mkdir python_workspace
cd python_workspace
git clone https://github.com/ansible/ansible-examples.git

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

# Now run your cloned script
cd ansible-examples
ansible-playbook <YOUR_PLAYBOOK_CMD>
cd Python
python3 Day_of_week.py
```

## Use case 3: Mount external code to container
Expand Down

0 comments on commit cdc769c

Please sign in to comment.