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

ansible: add second role to sample_project #259

Merged
merged 6 commits into from
Sep 14, 2023
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
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.
Loading