DevOps Buzz
  • Initial page
  • About me
  • Ansible
    • Cheat Sheet
    • Dynamic inventory
  • AKS
    • Cheat Sheet
    • Autoscale
    • Backup
    • Dashboard
    • Ingress
    • Node management
    • News
    • Persistent Volumes
  • Arch Linux
    • Docker
    • Install
    • Network
    • VirtualBox guest
  • Azure
    • API
    • CLI/Powershell
    • DevOps
      • Cheat Sheet
    • Application Gateway
    • Tools
    • Sops
  • AWS
    • Cheat Sheet
    • Tools
    • Cognito with Amplify and React
  • Bash / Shell
    • Cheat Sheet
    • Tools
  • Bitbucket
    • Cheat Sheet
  • CSS
    • Cheat Sheet
  • Distros
    • Manjaro
  • Docker
    • Cheat Sheet
    • ELK
    • Ubuntu NoVNC
    • Tools
    • Known errors and solutions
  • Elasticsearch
    • Cheat Sheet
    • Tools
  • ELK
    • Cheat Sheet
  • emacs
    • Cheat sheet
  • Gatekeeper (OPA)
    • Cheat Sheet
    • Developer Quick Start
  • GCP
    • Cheat Sheet
  • General
    • Tools
    • News
  • Git
    • Cheat Sheet
    • Tools
  • Golang
    • Cheat Sheet
  • Guidelines / Standards
    • Cheat Sheet
  • i3wm
    • Cheat Sheet
  • Ipsec
    • Cheat sheet
  • Istio
    • Cheat Sheet
  • Kind
    • Cheat Sheet
  • Kops
    • Cheat Sheet
  • Kubeadm
    • Cheat Sheet
    • Change serviceSubnet CIDR
    • Setup cluster
      • Azure
      • Bare-metal
      • Vagrant + VirtualBox
    • Multi master
    • Known errors and solutions
  • Kubernetes
    • Kubectl Cheat Sheet
    • etcd Cheat Sheet
    • Tools
    • News
    • Deployments
      • Deployment examples
      • Blue/Green Deployment
      • Canary Deployment
    • Dashboard
    • ELK
    • Helm
    • Ingress
    • logz.io
    • Minikube
    • Monitoring
    • Node Management
    • Operators
    • Security
    • Volumes
    • Networking
    • kube-controller-manager
      • Node crash recovery
    • Known errors and solutions
  • Lumen
    • Cheat Sheet
  • MACOS
    • Cheat Sheet
    • Qemu
    • Zsh
  • microk8s
    • Cheat Sheet
  • MongoDB
    • Cheat Sheet
    • Tools
  • MySQL
    • Cheat Sheet
  • Network
    • Tools
    • WDS - Wireless Distribution System
    • Expose server under NAT
  • nvim
    • Cheat Sheet
  • Openvpn
    • OpenVPN server on Ubuntu 18.06
    • Stunnel
  • PHP
    • Composer
  • Prometheus
    • Tools
  • Python
    • Cheat Sheet
    • Pydantic
    • Tools / Modules
    • Virtualenv
  • RabbitMQ
    • Cheat Sheet
  • ReactJS
    • Fixes
    • For beginners
  • Ruby
    • Cheat Sheet
    • Rails
    • rvm
  • Rundeck
    • Cheat Sheet
  • Rust
    • Cheat Sheet
  • Squid
    • Setup server
    • Expose NAT server
  • SRE
    • Cheat Sheet
  • SSH
    • Passwordless auth with RSA key
    • Reverse tunnel
    • Cheat Sheet
  • SSL
    • Cheat Sheet
    • certbot
  • STACK SETUP
    • Using EKS and Gitlab CI to deploy applications
  • Terraform
    • Cheat Sheet
    • Tools
  • Tmux
    • Cheat Sheet
  • Tor
    • Cheat Sheet
  • Ubuntu
    • Cheat Sheet
  • Vagrant
    • Cheat Sheet
  • VirtualBox
    • Cheat Sheet
  • Windows
    • Windows Docker
    • Fingerprint
    • SSH Client
    • Tools
    • VirtualBox
    • WSL
Powered by GitBook
On this page
  • Hosts
  • Host from variable
  • Ping
  • Ping all hosts
  • Ping localhost
  • Python virtualenv
  • Set RSA key path
  • Install packages
  • Decrypt
  • Decrypt string
  1. Ansible

Cheat Sheet

Useful Ansible commands.

Hosts

Host from variable

Playbook file:

- name: Your playbook name
  hosts: "{{ variable_host | default('localhost') }}"
  become: yes

To run it:

ansible-playbook playbooks/your-playbook-name.yml \
  --extra-vars "variable_host=PUT-YOUR-HOST-HERE"

Ping

Ping all hosts

ansible all -m ping -u root

Ping localhost

ansible all -m shell -a "ping -c 3 localhost" -u root

Python virtualenv

Make sure python will load all modules installed in your virtualenv.

ansible-playbook -v \
  playbooks/my-playbook.yaml \
  --extra-vars="ansible_python_interpreter=$(which python)"

Set RSA key path

ansible all -m ping -u root --private-key=~/.ssh/id_rsa

Install packages

ansible all -m apt -a "pkg=nginx state=latest update_cache=true" -u root

Decrypt

Decrypt string

Make sure your string variable is in group_vars/all.yml.

cat group_vars/all.yml

For example:

aws_access_key_id: !vault | $ANSIBLE_VAULT;1.1;AES256 39393635326661316162323939656138666562303765666138333737366139306535303432653537 3036323230616163343135393736343462346464646438320a373234383634646130666333316132 65623561393832666131656365646437643139626532623962646439376364333066323934663661 3031326632385365630a643162643562633231653132393139333737353837633931663764373239 64666537386530366564643336346630666530373664633630323730643261613563

Then run:

ansible YOUR-HOST-HERE -m debug -a 'var=aws_access_key_id'

PreviousAbout meNextDynamic inventory

Last updated 5 years ago