代码改变世界

2 - Ansible inventory and documentation

2021-08-07 13:08  WayneWei  阅读(26)  评论(0编辑  收藏  举报
  1. Ansible Inventory
    Before we dive into Ansible and practice, there is one more thing we need to do is take care with the ansible inventory, to declare our shell-node1 to be our managed machine, how ?
    There is a configure file, to declare our node1 to be ansible managed machine, the file on master node is named /etc/ansible/hosts

    Edit the file, include shell-node1 to the inventory as below:
    Run command vi /ect/ansible/hosts, then update below section. From the file it's provided examples, now we go with inventory group policy.
    Uncomment the section [webservers], then put with our shell-node1 host name (you can also using IP address) under that group.

     

     Save the file and exit. Now we can go play with ansible !

  2. Ansible modules
    Run below commands you will find all the modules which Ansible supported:
    ansible-doc -l | sort

     

     There are too much modules, from here we are going to pick a few common used to demonstrate only.

  3. Ansible module help
    By running command ansible-doc -s [module name] you can find the module help documentation, for example, we can determine how to use module [command] as below:
  4. Good, now we have Ansible all ready, and we know how to find help documentation for Ansible modules, next let's get our hand dirty, put practice on some common used modules.