Ansile (2) Service of the module

Source: Internet
Author: User
Tags syslog

Ansible Service Module

Parameter options from the official website, if there are discrepancies, the main website

Parameters
Whether you must Default Options Description
Arguments No

Command-line arguments
Enabled No

Yes

No

Set whether the service starts up
Name Yes

Service Name
Pattern No

Define a pattern, if there is no response through the status command to view the state of the service, the PS instruction will be found in the process based on that pattern, and if it matches, the service is still running
runlevel no default
service RunLevel
sleep no

set start and stop direct time interval
state no

started

stopped

Restarted

Reloaded

Start

Stop

Restart

Overload

Use No Auto
No attention


    1. Start the HTTP service

# ansible webserver -m service -a  "name=httpd state=started" 172.16.110.48  | SUCCESS => {     "Changed": true,       "name":  "httpd",      "state":  "started",       "status": {         "Activeentertimestampmonotonic":  "0 ",         " activeexittimestampmonotonic ": " 0 ",           "ActiveState":  "inactive",           "after":  "network.target remote-fs.target basic.target tmp.mount  Nss-lookup.target -.mount systemd-journald.socket system.slice ",           "Allowisolate":  "no",          " Assertresult ": " no ",           .......//too long      }} 172.16.110.47 | success => {       "changed":  true,         "name":  "httpd",        " State ": " started ",       " status ": {          "Activeentertimestampmonotonic":  "0",           "Activeexittimestampmonotonic":  "0",          " ActiveState ": " inactive ",         " after ": " Tmp.mount  remote-fs.target network.target system.slice -.mount systemd-journald.socket  Basic.target nss-lookup.target ",         " AllowIsolate ":   "No",           "Assertresult":  "no",  .......//too long    } }

2. Define Service Boot

# ansible webserver-m service-a "name=httpd enabled=yes"

3. Restart the network with parameters

# ansible webserver -m service -a  "name=network state=restarted  Arguments=ens33 " [WARNING]: Ignoring " arguments " as it is not used  in  "Systemd"  [WARNING]: Ignoring  "arguments"  as it is not  used in  "Systemd" 172.16.110.47 | success => {     "changed ": true,     " name ": " Network ",     " state ":  "Started",      "status": {         " Activeentertimestamp ": " TUE 2016-12-27 17:28:43 CST ",           "Activeentertimestampmonotonic":  "16144366",           "Activeexittimestampmonotonic":  "0",          " ActiveState ": " active ", &Nbsp;         "after":  "networkmanager-wait-online.service  Systemd-journald.socket system.slice basic.target networkmanager.service iptables.service  ip6tables.service network-pre.target ",         " Allowisolate ": " no ", .......    }}172.16.110.48 | success =>  {     "changed": true,         "name":   "Network",      "state":  "started",      "status":  {         "Activeentertimestamp":  "tue 2016-12-27  17:33:45 CST ",         " Activeentertimestampmonotonic ":   "11367077",          "activeexittimestampmonotonic":  "0 ",           "ActiveState":  "active        " after ":   "basic.target networkmanager.service networkmanager-wait-online.service  Systemd-journald.socket system.slice network-pre.target ip6tables.service iptables.service .....

4. Check the service run status and find it by matching field


# ansible webserver -m service -a  "name=atd pattern=/usr/sbin/atd  state=started "         [WARNING]: Ignoring " pattern "  as it is not used in  "Systemd"  [WARNING]: Ignoring  "pattern " as it is not used in " Systemd "172.16.110.47 | success = > {             "changed":  false,               "name":  "ATD",               "state":  "started",               "Status": {                  "Activeentertimestamp":  "tue  2016-12-27 17:28:34 CST ", &Nbsp;                 " Activeentertimestampmonotonic ": " 6416348 ",         " Activeexittimestampmonotonic ": " 0 ",         " ActiveState ":   "Active",          "after":  "system.slice  Systemd-user-sessions.service basic.target systemd-journald.socket syslog.target ",           "Allowisolate":  "no",           "Assertresult":  "yes",  .....    }}172.16.110.48 | success  => {     "changed": false,      "name":  " ATD ",     " state ": " started ",     " status ":  {        &nbsP; " Activeentertimestamp ": " TUE 2016-12-27 17:33:40 CST ",           "Activeentertimestampmonotonic":  "5455742",           "Activeexittimestampmonotonic":  "0",          " ActiveState ": " active ",         " after ": " Basic.target  systemd-user-sessions.service syslog.target systemd-journald.socket system.slice ",           "Allowisolate":  "no",           "Assertresult":  "yes",        .....     }}


This article is from the "take a deep Breath again" blog, make sure to keep this source http://ckl893.blog.51cto.com/8827818/1887105

Ansile (2) Service of the module

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.