Ansible learning-ansible
Ansible technologies (Automated O & M tools) are developed based on python.
Installation methods include yum, apt, pip, etc.
For example, pip: pip install ansible
The only requirement of ansible for the client is to have SSH and Python (if the python version is too low, install python-simplejson module)
The simplest ansible command:
Ansible-I/etc/ansible/hosts all-m command-a 'date'-u prod
Parameters:
-I specifies the location of the hosts file. hosts is a yaml file, and all indicates all groups in the hosts file.
-M specifies the ansible module. The command here indicates the ansible command module. There are many other modules, such as shell.
-A: Specify the args parameter.
-U indicates the user (because it is based on SSH authentication)
Common ansible commands:
Ansible # execute simple temporary commands (ad-hoc commands)
Ansible-playbook # execute playbook, playbook is a yaml file (as the main function of the Configuration Management Tool)
Ansible-doc # query ansible module documentation
Example:
---
-Hosts: cmdb
User: prod
Sudo: True
Tasks:
-Name: show the date
Shell: date
Y: show1
Handlers:
-Name: show1
Shell: ls
Run ansible-playbook user. yml
User. yml File
Hosts: Specifies the device group.
User: Specifies the ssh user
Sudo: whether to use the sudo permission
Tasks: keyword indicates the execution action
Name: name an action.
Yum: ansible specified Module