Skip to content

Commit

Permalink
ansible: add second role to sample_project (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
tungbq authored Sep 14, 2023
2 parents 8f9fd89 + a6c1384 commit c9b5623
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
23 changes: 22 additions & 1 deletion topics/ansible/projects/sample_project/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# Sample project looks like:
```
my_ansible_project/
├── roles/
│ ├── role1/
│ │ ├── tasks/
│ │ │ └── main.yml
│ │ ├── handlers/
│ │ │ └── main.yml
│ │ ├── templates/
│ │ ├── defaults/
│ │ └── meta/
│ └── role2/
│ ├── tasks/
│ ├── handlers/
│ ├── templates/
│ ├── defaults/
│ └── meta/
├── main.yml (your main playbook file)
```

# How to run
- Execute this command: `ansible-playbook -i inventory.ini main.yml` (tested on WSL2 Ubuntu)
- Execute this command: `ansible-playbook -i inventory.ini -v main.yml` (tested on WSL2 Ubuntu)
3 changes: 3 additions & 0 deletions topics/ansible/projects/sample_project/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
- name: Include ping-google
import_role:
name: ping-google
- name: Include check_up_time
import_role:
name: check_up_time
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: Execute uptime command
command: uptime
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# What is Handlers?
- In Ansible, handlers are a way to define a list of tasks that should be executed only if certain conditions are met, typically triggered by a notify directive in other tasks. Handlers are often used for actions that need to be taken only when specific changes occur during the playbook run, such as restarting services after configuration changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Template?
- In Ansible, templates are used to dynamically generate configuration files by inserting variable values and other dynamic content into a template file.
- Templates are a powerful way to manage configuration files for various services and applications across different hosts.

0 comments on commit c9b5623

Please sign in to comment.