Common ansible commands

Source: Internet
Author: User
Common ad-hoc commands are used to solve some common simple configuration commands, and these commands are executed quickly. Adhoc can be easy to use without having to write playbooks.
Man ansibleansible <pattern> [-F forks] [-M module] [-A ARGs] arguments pattern group name or host name, matching the hosts file. Options-V -- verbose mode. If the command is successfully executed, the detailed result is output.-I path -- inventory = path specifies the path of the host file, the default value is/etc/ansible/hosts-F num -- forks = num, which is an integer. The default value is 5, which specifies the number of synchronization processes enabled by fork. -- Private-Key = private_key_file_path use the specified file to establish an authentication connection-M name -- module-name = Name the specified Module name-M directory -- module-Path = directory specifies the directory of the module to load the module, the default value is/usr/share/ansible.-A arguments specifies the parameter-k -- ask-pass of the module and prompts you to enter the SSH password, instead of using SSH-based Key Authentication-k -- ask-Sudo-pass prompts to enter the sudo password, when using-o -- one-line with -- sudo to output the content-s -- Sudo-u in a row, use sudo to get the root permission-T directory -- tree = directory to put the output under the specified directory, name the name of each host-T seconds -- timeout = seconds timeout-B num -- background = num run the command in the background, kill the task after the specified num seconds-P num -- poll = num every num second, poll a background task, use-u username -- user = username together with-B to specify the execution user of the mobile terminal-u sudo_username -- Sudo-user = username sudo to sudo_username, replace root user-C connection -- connection = connection to specify the type of connection to be established. Generally, there is SSH, localhostfiles/etc/ansible/hosts default host file path/usr/share/ansible default module File Storage path/etc/ansible. CFG configuration file
File transferansible can transmit files to a remote host through SCP # ansible webservers-M copy-a "src =/etc/hosts DEST =/tmp/hosts" to/etc/ copy the hosts file to/tmp/hosts of all hosts in the webservers remote host group. The file module can change the File Permission and user group # ansible webservers-M file-a "DEST =/usr/local/src/test mode = 600 owner = WWW group = www" File the module can also create directories, similar to mkdir-P # ansible webservers-M file-a "DEST =/A/B/C/D mode = 755 owner = WWW group = WWW state = new", you can also delete file # ansible webserver-M file-a "DEST =/tmp/hosts state = absent"
Managing packagesansible also provides the yum module to install the software package to ensure that a package has been installed, but do not perform the update operation # ansible webservers-M Yum-a "name = Acme state = installed" view the software package with the specified version installed # ansible webservers-M Yum-a "name = acme-1.5 state = installed "check whether the installation package is the latest version # ansible webservers-M Yum-a" name = Acme state = Latest "ensure that a software package is not installed # ansible webservers -M Yum-a "name = Acme state = removed" ansible provides modules on platform for package management, if the software package you want to install is unavailable in the module, you can install the package through the commond module.
The users & groups 'user' module allows you to easily create or operate a user account, you can also delete a user # ansible all-M User-a "name = test Password = <ABC>" # ansible all-M User-a "name = test state = absent"
Managing services determines that the service is enabled # ansible all-M Service-a "name = httpd state = started" restart the service # ansibel all-M Service-a "name = httpd state = restarted "Close the service

# Ansible all-M Service-a "name = httpd state = stoped"



Translated man ansible

Common ansible commands

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.