真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

運(yùn)維自動化神器ansible之group模塊

ansible之group模塊

group模塊是用來添加或者刪除組

成都創(chuàng)新互聯(lián)為您提適合企業(yè)的網(wǎng)站設(shè)計?讓您的網(wǎng)站在搜索引擎具有高度排名,讓您的網(wǎng)站具備超強(qiáng)的網(wǎng)絡(luò)競爭力!結(jié)合企業(yè)自身,進(jìn)行網(wǎng)站設(shè)計及把握,最后結(jié)合企業(yè)文化和具體宗旨等,才能創(chuàng)作出一份性化解決方案。從網(wǎng)站策劃到網(wǎng)站制作、網(wǎng)站建設(shè), 我們的網(wǎng)頁設(shè)計師為您提供的解決方案。

首先使用ansible-doc來查看用法

[root@note0 ansible]# ansible-doc -s group
- name: Add or remove groups
  group:
      gid:                   # Optional `GID' to set for the group.
      local:                 # Forces the use of "local" command alternatives on platforms that implement it. This is useful in environments that use centralized
                               authentication when you want to manipulate the local groups. (e.g. it uses `lgroupadd' instead of
                               `groupadd'). This requires that these commands exist on the targeted host, otherwise it will be a fatal
                               error.
      name:                  # (required) Name of the group to manage.
      non_unique:            # This option allows to change the group ID to a non-unique value. Requires `gid'. Not supported on macOS or BusyBox distributions.
      state:                 # Whether the group should be present or not on the remote host.
      system:                # If `yes', indicates that the group created is a system group.

通過上面的參數(shù)列表我們可以了解到group模塊有幾個重要屬性

OPTIONS (= is mandatory):選項(xiàng)前面為=的為必填參數(shù)

一、name

= name
        Name of the group to manage.
        type: str

要操作的group的組名,string類型,必填項(xiàng)

1.1、示例

創(chuàng)建一個名字為test的組。

[root@note0 ~]# ansible local -m group -a "name=test"
176.16.128.1 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true,#可以看到changed狀態(tài)為true,代表已經(jīng)在主機(jī)添加組成功。
    "gid": 1000, 
    "name": "test", 
    "state": "present", 
    "system": false
}

查看主機(jī)/etc/group文件驗(yàn)證

[root@note1 ~]# cat /etc/group
test:x:1000:

二、state

- state
        Whether the group should be present or not on the remote host.
        (Choices: absent, present)[Default: present]
        type: str

state用于指定用戶組在遠(yuǎn)程主機(jī)上是否被更改或刪除,string類型。
有兩個選項(xiàng):absent,present。默認(rèn)值為present,absent為刪除組。

2.1、示例

我們來刪除一下剛才創(chuàng)建的組。

[root@note0 ~]# ansible local -m group -a "name=test state=absent"
176.16.128.1 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "name": "test", 
    "state": "absent"
}

三、gid

- gid
        Optional `GID' to set for the group.
        [Default: (null)]
        type: int

gid用于設(shè)定用戶組gid,int類型,默認(rèn)值為空

3.1、示例

創(chuàng)建一個gid為1005,名字為test的組。

[root@note0 ~]# ansible local -m group -a "name=test gid=1005 state=present"
176.16.128.1 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "gid": 1005, 
    "name": "test", 
    "state": "present", 
    "system": false
}

查看主機(jī)/etc/group文件,我們可以看到新創(chuàng)建的組gid為1005。

[root@note1 ~]# cat /etc/group
test:x:1005:

四、system

- system
        If `yes', indicates that the group created is a system group.
        [Default: False]
        type: bool

system用于指定創(chuàng)建的用戶組是否為系統(tǒng)組,布爾類型,可用選項(xiàng)false,true,默認(rèn)為false

4.1、示例

創(chuàng)建一個名字為test的系統(tǒng)組。

[root@note0 ~]# ansible local -m group -a "name=test state=present system=true"
176.16.128.1 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "gid": 994, 
    "name": "test", 
    "state": "present", 
    "system": true
}

查看主機(jī)/etc/group文件驗(yàn)證

[root@note1 ~]# cat /etc/group
test:x:994:

可以看到test組的gid為994,gid小于1000為系統(tǒng)組。


文章標(biāo)題:運(yùn)維自動化神器ansible之group模塊
網(wǎng)站鏈接:http://weahome.cn/article/piigjp.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部