How to use ansible common commands and modules

Source: Internet
Author: User

    1. Ansible is the core part of the instruction, which is mainly used to execute the AD-HOC (Point-to-point) command, which is a single command. The default is to follow the host and Options section, which is the command module when the module is not specified by default.


2. The module that is used by default can be modified in ansible.cfg. /etc/ansible/ansible.cfg


Ansible Common Command parsing:

See which modules are currently supported by Ansible: Ansible-doc-l

To view the parameters that a module can use: Ansible-doc-s copy (eg:copy module)

Ansible usage:

Ansible host name-M module name-a module parameter

-M: The name of the module, if a single command does not have to add-M, the default GO command

-A: module parameters, if the module is command,-a followed by the command parameters

-I: Specify the Hosts file location default:/etc/ansible/hosts

-F: Number of parallel tasks, must be integers

-U: Specify remote user, default is root


Ansible-playbook: It is important to accumulate the standard of writing.

The ansible-galaxy instruction is used to easily download third-party extensions from the https://galaxy.ansible.com/site, and we can visually understand them like Yum under CentOS, Pip or easy_install under Python.

Ansible-vault is mainly used in the configuration file contains sensitive information, do not want him to be seen, vault can help you encrypt/decrypt this configuration file, is a high-level usage. Mainly for playbooks for example, when it comes to configuring passwords or other variables, it can be encrypted by this directive, so that what we see through cat is a cipher string class of files that need to be entered in a pre-set password to open the edit. This playbook file needs to be added with the –ask-vault-pass parameter when it executes, and the password must be entered before it can be executed properly.


Common modules:

Copy module: Src=/dir/file dest=/dir/

File module:

Cron module:

Group module:

User module:

Yum module:

Service module:

Script module:

Ping module:

Command module:

Raw modules:

Get_url module:

Synchronize module:


Please refer to ansible website for all remaining modules:

Http://docs.ansible.com/ansible/list_of_all_modules.html

Playbook Writing Specification:

Http://docs.ansible.com/ansible/playbooks_intro.html

This article is from the "Ignatius Blog" blog, make sure to keep this source http://ignatius.blog.51cto.com/10028892/1882312

How to use ansible common commands and modules

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.