What does the Ansible module know?

Source: Internet
Author: User

What does the Ansible module know?

I used ansible in the company for a while and shared the introduction about the use of the ansible module.

Ansible provides many modules by default. In Linux, we can run the ansible-doc-l command to check which modules are supported by ansible, you can use the ansible-doc-s Module name to view the parameters available for this module.

The following describes several common modules:

Copy Module
File Module
Cron Module
Group Module
User Module
Yum Module
Service Module
Script Module
Ping Module
Command Module
Raw Module
Get_url Module
Synchronize Module

Functions and usage of Ansible and Docker

Ansible batch build LAMP Environment

Ansible: a configuration management and IT automation tool

Install and deploy Ansible in Linux

Copy module:

Objective: To copy the. sh file under the master/root directory to a specified Node

Command: ansible 10.1.1.113-m copy-a 'src =/root/a. sh dest =/tmp /'

Execution result:

File module:

Purpose: To change the/tmp/t. sh permission on a specified node to 755, and the owner and group are root.

Command: ansible all-m file-a "dest =/tmp/t. sh mode = 755 owner = root group = root"

Execution result:

Cron module:

Purpose: To define a scheduled task on a specified node and update the task to the master node every 3 minutes.

Command: ansible all-m cron-a 'name = "custom job" minute = */3 hour = * day = * month = * weekday = * job = "/usr/sbin/ntpdate 172.16.254.139 "'

Execution result:

Group module:

Objective: to create a group named nolinux and gid 2014 on all nodes

Command: ansible all-m group-a 'Gid = 2014 name = nolinux'

Execution result:

User Module:

Purpose: To create a user with the username of nolinux and a group of users with the name of nolinux on a specified Node

Command: ansible 10.1.1.113-m user-a 'name = nolinux groups = nolinux state = present'

Run the following command:

Supplement: User deletion example

Yum module:

Objective: To install the lrzsz service on a specified Node

Command: ansible all-m yum-a "state = present name = httpd"

Execution result:

Service module:

Purpose: To start the puppet service on a specified node and enable it to start automatically

Command: ansible 10.1.1.113-m service-a 'name = puppet state = restarted enabled = yes'

Execution result:

  • 1
  • 2
  • Next Page

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.