Ansible

Configuration files

  • Default inventory file: /etc/ansible/hosts
  • Configuration file: /etc/ansible/ansible.cfg

Commands

  • List all available modules: ansible-doc -l
  • Display the manual for a specific module: ansible-doc firewalld
  • List all facts on the localhost: ansible all -m setup -k
  • Install the required package for the client: yum install python-simplejson

ad-hoc commands

  • List all servers from host inventory file: ansible all --list-hosts
  • Test the connection: ansible -m ping all -k
  • Check free space: ansible -m command -a "df -h /" all -k
  • Update all packages: ansible -m yum -a "name=* state=latest" all
  • Add a username:
ansible all -m user -a 'name=daniel uid=501 createhome=yes shell=/bin/bash comment="Daniel"' -k
ansible all -m shell -a 'chage -I '-1' -m '-1' -M '-1' -W '-1' daniel' -k

Links