Git Product home page Git Product logo

ansible-playground's Introduction

Red Hat Ansible Playground

1. Introduction

In this repo, I want to explore some of the basic Ansible features that allow you to manage your VMs.

2. Setting up a local environment

Manage the new VM
kcli create plan -f docs/kcli-template-rhel92.yaml rhel92 # Create a basic plan with one VM
kcli plan -s rhel92 # Start the plan
kcli plan -w rhel92 # Stop the plan
kcli list vm        # Show VMs status
kcli plan -d rhel92 # Delete the plan
Add the VM to the /etc/hosts
sudo bash -c 'echo "192.168.122.100 rhel92.vm" >> /etc/hosts'
Copy your ssh keys
ssh-copy-id rhel92.vm

3. Ansible Automation Platform

Red Hat Ansible Automation Platform is an end-to-end automation platform to configure systems, deploy software, and orchestrate advanced workflows.

3.1. Vi useful configuration

autocmd FileType yaml setlocal ai ts=2 sw=2 et

4. Ansible basics

4.1. Get documentation

List all the available modules
# List available images
ansible-navigator images

# List available modules
ansible-navigator doc -l

# List available collections
ansible-navigator collections

# Get documentation for one module
ansible-navigator -s doc module_name

# Create a role from scratch
ansible-galaxy init alvaro.testing
Autogenerate ansible config file with defaults
ansible-navigator config init --disabled > ansible.cfg
Autogenerate ansible-navigator YAML with defaults
ansible-navigator settings --sample > ansible-navigator.yml

4.2. Ansible Vault

# Create secret
ansible-vault create --vault-password-file=vault-pass.txt group_vars/web/vault.yml

# Edit Secret
ansible-vault edit --vault-password-file=vault-pass.txt group_vars/web/vault.yml

# Execute Plays with password
ansible-navigator run -m stdout --vault-password-file=vault-pass.txt plays/20_variables.yaml

4.3. Gather Facts

ansible-navigator run -m stdout plays/30_facts.yaml

4.4. Loops, Conditionals, and Handlers

ansible-navigator run -m stdout --ask-become-pass plays/40_task_control.yaml

4.5. Manage Files

ansible-navigator run -m stdout plays/50_deploy_files.yaml

4.6. Complex Plays

ansible-navigator run -m stdout --ask-become-pass plays/60_complex_plays.yaml

4.7. Roles and Collections

Install existing roles and collections
# Install a Role
ansible-galaxy role install -r roles/requirements.yml

# Install a Collection
ansible-galaxy collection install -r collections/requirements.yml -p collections

KCS about System Roles availability and support: https://access.redhat.com/articles/3050101

ansible-navigator run -m stdout --ask-become-pass plays/70_roles_and_collections.yaml

4.8. Manage Subscriptions

ansible-navigator run -m stdout --ask-become-pass plays/90_rh_subs.yaml
๐Ÿ’ก
I strongly recommend the exercises proposed by mateuszstompor in his repo rhce-ex294-exam. He has some generic exercises that provide a good starting point to make sure that you control the topics that appear in the RHCE exam for RHEL 9.

ansible-playground's People

Contributors

alvarolop avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.