Skip to content

KevinShih-689/ansible-practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ansible-practice

πŸš€ To practice how to write ansible playbook.

Directory Layout

ansible-practice/
β”œβ”€β”€ inventories/
β”‚   β”œβ”€β”€ production/
β”‚   β”‚   β”œβ”€β”€ hosts
β”‚   β”‚   └── group_vars/
β”‚   └── staging/
β”‚       β”œβ”€β”€ hosts
β”‚       └── group_vars/
β”œβ”€β”€ roles/
β”‚   β”œβ”€β”€ common/
β”‚   β”‚   β”œβ”€β”€ tasks/
β”‚   β”‚   β”œβ”€β”€ handlers/
β”‚   β”‚   β”œβ”€β”€ files/
β”‚   β”‚   β”œβ”€β”€ defaults/
β”‚   β”‚   β”œβ”€β”€ templates/
β”‚   β”‚   └── vars/
β”‚   β”‚       β”œβ”€β”€ main.yml
β”‚   β”‚       └── more.yml
β”‚   └── webserver/
β”‚       β”œβ”€β”€ tasks/
β”‚       β”œβ”€β”€ files/
β”‚       └── templates/
β”œβ”€β”€ site.yml ( Master Playbook )
β”œβ”€β”€ deploy-webserver.yml
β”œβ”€β”€ provision-infrastructure.yml
β”œβ”€β”€ production.yml
β”œβ”€β”€ staging.yml
└── ansible.cfg

Before you start

⚑ Remember to share your controller ssh public key id_rsa.pub with the worker node you want to control.
ℹ️ The list of worker nodes will store in inventories folder

Sharing Controller public key

  1. Generate ssh key in Controller

    $ ssh key-keygen
    
  2. Copy public key to worker node

    Controller
    $ cat ./.ssh/id_rsa.pub
    ssh-rsa XXXXXXXXXXXX...
    
    Worker Node
    $ vi ./.ssh/authorized_keys
    

Playbook

ℹ️ Remember to execute the ansible command in the project's root directory.
Name Description roles
test-playbook Test to ping managed node ping-sample
install-docker-playbook Install Docker docker-installer
pip-installer

Virtual Machine

  • Control Node

  • Managed Node

    • RHCSAPrac
      • RHEL 8
      • IP: 10.250.75.112
    • RockyLinux
      • Rocky Linux 8.7
      • IP: 10.250.75.116

VS Code Tools

Reference

Alt

About

πŸš€ To practice how to write ansible playbook.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published