【移動(dòng)應(yīng)用開發(fā)技術(shù)】MCollective架構(gòu)篇4-MCollective各種插件的部署及測試_第1頁
【移動(dòng)應(yīng)用開發(fā)技術(shù)】MCollective架構(gòu)篇4-MCollective各種插件的部署及測試_第2頁
【移動(dòng)應(yīng)用開發(fā)技術(shù)】MCollective架構(gòu)篇4-MCollective各種插件的部署及測試_第3頁
【移動(dòng)應(yīng)用開發(fā)技術(shù)】MCollective架構(gòu)篇4-MCollective各種插件的部署及測試_第4頁
【移動(dòng)應(yīng)用開發(fā)技術(shù)】MCollective架構(gòu)篇4-MCollective各種插件的部署及測試_第5頁
已閱讀5頁,還剩20頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

【移動(dòng)應(yīng)用開發(fā)技術(shù)】MCollective架構(gòu)篇4-MCollective各種插件的部署及測試

零基礎(chǔ)學(xué)習(xí)Puppet自動(dòng)化配置管理系列文檔MCollective只是一個(gè)框架,如果需要在上面發(fā)揮各種作用,那就需要各種插件的支持。官方提供了很多這方面的插件,除此之外,還有第三方的插件,比如shell插件等,下面會(huì)介紹各種插件的安裝,以及插件之間如何組合進(jìn)行使用。1、在mcollectiveclient端和server端安裝各種官網(wǎng)plugins首先去官網(wǎng)下載各個(gè)插件1.1下載collective-client端[root@linuxmaster1poc

~]#

rpm

-qa

|

grep

mco

mcollective-service-common-3.1.2-1.noarch

mcollective-client-2.2.4-1.el6.noarch

mcollective-service-client-3.1.2-1.noarch

mcollective-common-2.2.4-1.el6.noarch

mcollective-iptables-common-3.0.1-1.noarch

mcollective-filemgr-client-1.0.1-1.noarch

mcollective-nrpe-client-3.0.2-1.noarch

mcollective-puppet-client-1.6.0-1.noarch

mcollective-nrpe-common-3.0.2-1.noarch

mcollective-filemgr-common-1.0.1-1.noarch

mcollective-iptables-client-3.0.1-1.noarch

mcollective-puppet-common-1.6.0-1.noarch

mcollective-facter-facts-1.0.0-1.noarch

mcollective-package-client-4.2.0-1.noarch

mcollective-package-common-4.2.0-1.noarch1.2下載mcollecitve-server端[root@linux57poc

~]#

rpm

-qa

|

grep

mco

mcollective-nrpe-common-3.0.2-1

mcollective-puppet-common-1.6.0-1

mcollective-iptables-common-3.0.1-1

mcollective-iptables-agent-3.0.1-1

mcollective-2.2.4-1.el5

mcollective-package-common-4.2.0-1

mcollective-service-common-3.1.2-1

mcollective-service-agent-3.1.2-1

mcollective-puppet-agent-1.6.0-1

mcollective-package-agent-4.2.0-1

mcollective-filemgr-common-1.0.1-1

mcollective-common-2.2.4-1.el5

mcollective-facter-facts-1.0.0-1

mcollective-filemgr-agent-1.0.1-1

mcollective-nrpe-agent-3.0.2-1以上安裝可寫個(gè)package模塊執(zhí)行,以下只針對mcollectiveserver端,安裝完成之后記得重啟服務(wù),如果寫了service模塊可以自動(dòng)刷新1.3編寫plugins.ppclass

mcollective::plugins{

include

mcollective::plugins_puppet,

mcollective::plugins_facter,

mcollective::plugins_filemgr,

mcollective::plugins_iptables,

#

mcollective::plugins_nettest,

#這個(gè)安裝需要依賴包

ruby-net-ping,沒找到

mcollective::plugins_nrpe,

mcollective::plugins_package,

mcollective::plugins_service

}

#mco-client

need

install

mcollective-puppet-client

and

mcollective-puppet-common

class

mcollective::plugins_puppet{

package

{

['mcollective-puppet-agent','mcollective-puppet-common']:

ensure

=>

installed,

require

=>

Class["mcollective::install"]

}

}

#mco-client

need

install

mcollective-facter-facts

class

mcollective::plugins_facter{

package

{

'mcollective-facter-facts':

ensure

=>

installed,

require

=>

Class["mcollective::install"]

}

}

#mco-client

need

install

mcollective-filemgr-client

and

mcollective-filemgr-common

class

mcollective::plugins_filemgr{

package

{

['mcollective-filemgr-agent','mcollective-filemgr-common']:

ensure

=>

installed,

require

=>

Class["mcollective::install"]

}

}

#mco-client

need

install

mcollective-iptables-client

and

mcollective-iptables-common

class

mcollective::plugins_iptables{

package

{

['mcollective-iptables-agent','mcollective-iptables-common']:

ensure

=>

installed,

require

=>

Class["mcollective::install"]

}

}

#mco-client

need

install

mcollective-nettest-client

and

mcollective-nettest-common

class

mcollective::plugins_nettest{

package

{

['mcollective-nettest-agent','mcollective-nettest-common']:

ensure

=>

installed,

require

=>

Class["mcollective::install"]

}

}

#mco-client

need

install

mcollective-nrpe-client

and

mcollective-nrpe-common

class

mcollective::plugins_nrpe{

package

{

['mcollective-nrpe-agent','mcollective-nrpe-common']:

ensure

=>

installed,

require

=>

Class["mcollective::install"]

}

}

#mco-client

need

install

mcollective-package-client

and

mcollective-package-common

class

mcollective::plugins_package{

package

{

['mcollective-package-agent','mcollective-package-common']:

ensure

=>

installed,

require

=>

Class["mcollective::install"]

}

}

#mco-client

need

install

mcollective-service-client

and

mcollective-service-common

class

mcollective::plugins_service{

package

{

['mcollective-service-agent','mcollective-service-common']:

ensure

=>

installed,

require

=>

Class["mcollective::install"]

}

}1.4編寫conf.ppclass

mcollective::service{

service

{

'mcollective':

ensure

=>

running,

hasstatus

=>

true,

hasrestart

=>

true,

enable

=>

true,

subscribe

=>

Class['mcollective::config'],

}

}1.5mcollective-client端安裝好之后,可通過mco命令查看[root@linuxmaster1poc

~]#

mco

The

Marionette

Collective

version

2.2.4

usage:

/usr/bin/mco

command

<options>

Known

commands:

completion

facts

filemgr

find

help

inventory

iptables

nrpe

package

ping

plugin

puppet

rpc

service

shell

Type

'/usr/bin/mco

help'

for

a

detailed

list

of

commands

and

'/usr/bin/mco

help

command'

to

get

detailed

help

for

a

command1.6mcollective-server端安裝好之后,可在mco-client端查看[root@linuxmaster1poc

~]#

mco

inventory

linux57poc

Inventory

for

linux57poc:

Server

Statistics:

Version:

2.2.4

Start

Time:

Fri

Dec

13

08:15:46

+0800

2013

Config

File:

/etc/mcollective/server.cfg

Collectives:

mcollective

Main

Collective:

mcollective

Process

ID:

23268

Total

Messages:

16

Messages

Passed

Filters:

16

Messages

Filtered:

0

Expired

Messages:

0

Replies

Sent:

15

Total

Processor

Time:

0.71

seconds

System

Time:

0.15

seconds

Agents:

#都加載上了

discovery

filemgr

nrpe

package

puppet

rpcutil

service

shell

Data

Plugins:

agent

fstat

nrpe

puppet

resource

service

Configuration

Management

Classes:

No

classes

applied

Facts:

architecture

=>

x86_64

augeasversion

=>

0.10.0

bios_release_date

=>

06/22/2012

bios_vendor

=>

Phoenix

Technologies

LTD

bios_version

=>

6.00

blockdevice_fd0_size

=>

4096

blockdevice_hdc_size

=>

3834736640

。。。注意:接下來測試各種命令的操作組合,這里只舉一些例子,更多信息可參考--help或者參考官網(wǎng)2、安裝shell插件插件下載地址:/kisspuppet/mcollective-plugins,有g(shù)ithub客戶端的童鞋可直接clone/kisspuppet/mcollective-plugins.git2.1、下載插件放在對應(yīng)的目錄里即可mcollective-client端

[root@linuxmaster1poc

~]#

ll

/usr/libexec/mcollective/mcollective/application/

|

grep

shell

-rw-r--r--

1

root

root

1601

Aug

6

06:36

shell.rb

[root@linuxmaster1poc

~]#

ll

/usr/libexec/mcollective/mcollective/agent/

|

grep

shell

-rw-r--r--

1

root

root

1017

Aug

6

06:36

shell.ddl

-rw-r--r--

1

root

root

862

Aug

6

06:36

shell.rb

mcollective-server端

[root@linux57poc

agent]#

ll

/usr/libexec/mcollective/mcollective/agent/

|

grep

shell

-rw-r--r--

1

root

root

1017

Aug

6

06:36

shell.ddl

-rw-r--r--

1

root

root

862

Aug

6

06:36

shell.rb備注:mcollective-server端部署完成之后,記得重啟mcollective服務(wù)。2.2、查看shell插件是否加載成功從下面可以看出mcollective-client端shell插件已經(jīng)有了[root@linuxmaster1poc

~]#

mco

The

Marionette

Collective

version

2.2.4

usage:

/usr/bin/mco

command

Known

commands:

completion

facts

find

help

inventory

ping

plugin

puppet

rpc

shell

#shell插件加載OK

Type

'/usr/bin/mco

help'

for

a

detailed

list

of

commands

and

'/usr/bin/mco

help

command'

to

get

detailed

help

for

a

command從下面可以看出mcollective-server端shell插件也加載了[root@linuxmaster1poc

~]#

mco

inventory

linux57poc

Inventory

for

linux57poc:

Server

Statistics:

Version:

2.2.4

Start

Time:

Fri

Dec

13

01:14:14

+0800

2013

Config

File:

/etc/mcollective/server.cfg

Collectives:

mcollective

Main

Collective:

mcollective

Process

ID:

23898

Total

Messages:

10

Messages

Passed

Filters:

10

Messages

Filtered:

0

Expired

Messages:

0

Replies

Sent:

9

Total

Processor

Time:

0.73

seconds

System

Time:

0.17

seconds

Agents:

discovery

puppet

rpcutil

shell

#shell插件加載OK

Data

Plugins:

agent

fstat

puppet

resource

Configuration

Management

Classes:

No

classes

applied

Facts:

architecture

=>

x86_64

augeasversion

=>

0.10.0

bios_release_date

=>

06/22/2012

bios_vendor

=>

Phoenix

Technologies

LTD

bios_version

=>

6.00

blockdevice_fd0_size

=>

4096

blockdevice_hdc_size

=>

3834736640

blockdevice_sda_model

=>

Virtual

disk

blockdevice_sda_size

=>

42949672960

。。。2.3、通過shell插件執(zhí)行shell命令mco

shell幫助信息

[root@linuxmaster1poc

~]#

mco

shell

--help

MCollective

Distributed

Shell

Usage:

mco

shell

<CMD>

The

CMD

is

a

string

EXAMPLES:

mco

shell

uptime

--np,

--no-progress

Do

not

show

the

progress

bar

-1,

--one

Send

request

to

only

one

discovered

nodes

--batch

SIZE

Do

requests

in

batches

--batch-sleep

SECONDS

Sleep

time

between

batches

--limit-seed

NUMBER

Seed

value

for

deterministic

random

batching

--limit-nodes,

--ln,

--limit

COUNT

Send

request

to

only

a

subset

of

nodes,

can

be

a

percentage

-j,

--json

Produce

JSON

output

--display

MODE

Influence

how

results

are

displayed.

One

of

ok,

all

or

failed

-c,

--config

FILE

Load

configuratuion

from

file

rather

than

default

-v,

--verbose

Be

verbose

-h,

--help

Display

this

screen

Common

Options

-T,

--target

COLLECTIVE

Target

messages

to

a

specific

sub

collective

--dt,

--discovery-timeout

SECONDS

Timeout

for

doing

discovery

-t,

--timeout

SECONDS

Timeout

for

calling

remote

agents

-q,

--quiet

Do

not

be

verbose

--ttl

TTL

Set

the

message

validity

period

--reply-to

TARGET

Set

a

custom

target

for

replies

--dm,

--disc-method

METHOD

Which

discovery

method

to

use

--do,

--disc-option

OPTION

Options

to

pass

to

the

discovery

method

--nodes

FILE

List

of

nodes

to

address

Host

Filters

-W,

--with

FILTER

Combined

classes

and

facts

filter

-S,

--select

FILTER

Compound

filter

combining

facts

and

classes

-F,

--wf,

--with-fact

fact=val

Match

hosts

with

a

certain

fact

-C,

--wc,

--with-class

CLASS

Match

hosts

with

a

certain

config

management

class

-A,

--wa,

--with-agent

AGENT

Match

hosts

with

a

certain

agent

-I,

--wi,

--with-identity

IDENT

Match

hosts

with

a

certain

configured

identity

The

Marionette

Collective

2.2.4顯示對端uptime命令負(fù)載情況[root@linuxmaster1poc

~]#

mco

shell

"uptime"

Do

you

really

want

to

send

this

command

unfiltered?

(y/n):

y

Discovering

hosts

using

the

mc

method

for

2

second(s)

3

Host:

linux58poc

Statuscode:

0

Output:

02:45:02

up

21:10,

2

users,

load

average:

0.00,

0.00,

0.00

Host:

linux64poc

Statuscode:

0

Output:

02:45:02

up

20:59,

1

user,

load

average:

0.00,

0.00,

0.00

Host:

linux57poc

Statuscode:

0

Output:

02:45:02

up

21:04,

3

users,

load

average:

0.00,

0.00,

0.00顯示所有節(jié)點(diǎn)/etc/password文件中puppet用戶哪一行[root@linuxmaster1poc

~]#

mco

shell

"cat

/etc/passwd

|

grep

puppet"

Do

you

really

want

to

send

this

command

unfiltered?

(y/n):

y

Discovering

hosts

using

the

mc

method

for

2

second(s)

3

Host:

linux58poc

Statuscode:

0

Output:

puppet:x:52:52:Puppet:/var/lib/puppet:/sbin/nologin

Host:

linux64poc

Statuscode:

0

Output:

puppet:x:52:52:Puppet:/var/lib/puppet:/sbin/nologin

Host:

linux57poc

Statuscode:

0

Output:

puppet:x:52:52:Puppet:/var/lib/puppet:/sbin/nologin修改其中一臺(tái)主機(jī)的root密碼[root@linuxmaster1poc

~]#

mco

shell

"echo

redhat

|

passwd

root

--stdin"

-I

linux57poc

Host:

linux57poc

Statuscode:

0

Output:

Changing

password

for

user

root.

passwd:

all

authentication

tokens

updated

successfully.備注:更多操作步驟可參考mcoshell--help幫助。警告:基于mcollective的shell插件雖然功能很強(qiáng)大,除了動(dòng)態(tài)顯示的命令之外,其它root能操作的,它基本上都能操作。所以操作也非常危險(xiǎn),可根據(jù)生產(chǎn)環(huán)境實(shí)際情況而定。注意:接下來測試各種命令的操作組合,這里只舉一些例子,更多信息可參考--help或者參考官網(wǎng)3、組合mcollective各種plugins完成各種任務(wù)組合3.1、停止操作系統(tǒng)為RHEL5.x服務(wù)器的crond任務(wù)先查看5.x系統(tǒng)crond的狀態(tài),使用插件service、facts[root@linuxmaster1poc

~]#

mco

service

crond

status

-F

operatingsystemmajrelease=5

*

[

============================================================>

]

2

/

2

linux57poc:

running

linux58poc:

running

Summary

of

Service

Status:

running

=

2

Finished

processing

2

/

2

hosts

in

184.79

ms然后通過service插件停止服務(wù),使用插件service、facts[root@linuxmaster1poc

~]#

mco

service

crond

stop

-F

operatingsystemmajrelease=5

*

[

============================================================>

]

2

/

2

Summary

of

Service

Status:

stopped

=

2

Finished

processing

2

/

2

hosts

in

914.76

ms再次查看過濾的主機(jī)crond服務(wù)是否被停掉,使用插件service、facts[root@linuxmaster1poc

~]#

mco

service

crond

status

-F

operatingsystemmajrelease=5

*

[

============================================================>

]

2

/

2

linux57poc:

stopped

linux58poc:

stopped

Summary

of

Service

Status:

stopped

=

2

Finished

processing

2

/

2

hosts

in

125.87

ms也可以通過shell插件實(shí)現(xiàn),使用到插件為shell、service、facts[root@linuxmaster1poc

~]#

mco

shell

"service

crond

status"

-F

operatingsystemmajrelease=5

Discovering

hosts

using

the

mc

method

for

2

second(s)

2

Host:

linux57poc

Statuscode:

3

Output:

crond

is

stopped

Host:

linux58poc

Statuscode:

3

Output:

crond

is

stopped3.2、使用mco對自定義fact_apply4=app的主機(jī)做一次變更,要求環(huán)境為testing,模式為noop首先查看下那些主機(jī)具備有這個(gè)自定義fact,使用的插件為find、inventory[root@linuxmaster1poc

~]#

for

i

in

`mco

find`

;

do

echo

$i;

mco

inventory

$i

|

grep

fact_apply4;

done

linux58poc

fact_apply4

=>

app

linux57poc

linux64poc

fact_apply4

=>

app其次按要求做變更即可,使用到的插件為puppet,facts[root@linuxmaster1poc

~]#

mco

puppet

-v

runonce

--environment=testing

--noop

-F

fact_apply4=app

Discovering

hosts

using

the

mc

method

for

2

second(s)

2

*

[

============================================================>

]

2

/

2

linux64poc

:

OK

{:summary=>

"Started

a

background

Puppet

run

using

the

'puppet

agent

--onetime

--daemonize

--color=false

--splay

--splaylimit

30

--noop

--environment

testing'

command"}

linux58poc

:

OK

{:summary=>

"Started

a

background

Puppet

run

using

the

'puppet

agent

--onetime

--daemonize

--color=false

--splay

--splaylimit

30

--noop

--environment

testing'

command"}

rpc

stats

Nodes:

2

/

2

Pass

/

Fail:

2

/

0

Start

Time:

Fri

Dec

13

09:10:50

+0800

2013

Discovery

Time:

2003.32ms

Agent

Time:

884.34ms

Total

Time:

2887.67ms變更完成后,迅速查看節(jié)點(diǎn)運(yùn)行情況,使用到的插件為puppet

[root@linuxmaster1poc~]#mcopuppetstatus

*

[

============================================================>

]

3

/

3

linux64poc:

Currently

idling;

last

completed

run

54

seconds

ago

linux58poc:

Currently

applying

a

catalog;

last

completed

run

1

minutes

12

seconds

ago

linux57poc:

Currently

stopped;

last

completed

run

22

minutes

57

seconds

ago

Summary

of

Applying:

false

=

2

true

=

1

Summary

of

Daemon

Running:

running

=

2

stopped

=

1

Summary

of

Enabled:

enabled

=

3

Summary

of

Idling:

false

=

2

true

=

1

Summary

of

Status:

idling

=

1

stopped

=

1

applying

a

catalog

=

1

Finished

processing

3

/

3

hosts

in

263.72

ms3.3、遠(yuǎn)程改所有系統(tǒng)為RHEL6.4主機(jī)root的密碼,使用到的插件為shell,facts[root@linuxmaster1poc

~]#

mco

shell

"echo

redhat

|

passwd

root

--stdin"

-F

operatingsystemrelease=6.4

Discovering

hosts

using

the

mc

method

for

2

second(s)

1

Host:

linux64poc

Statuscode:

0

Output:

Changing

password

for

user

root.

passwd:

all

authentication

tokens

updated

successfully.3.4、查看所有節(jié)點(diǎn)puppet和facter安裝包的版本信息,使用到的插件為package[root@linuxmaster1poc

~]#

mco

package

status

puppet

*

[

============================================================>

]

3

/

3

linux64poc:

puppet-2.7.23-1.el6.noarch

linux57poc:

puppet-2.7.23-1.el5.noarch

linux58poc:

puppet-2.7.23-1.el5.noarch

Summary

of

Arch:

noarch

=

3

Summary

of

Ensure:

2.7.23-1.el5

=

2

2.7.23-1.el6

=

1

Finished

processing

3

/

3

hosts

in

635.21

ms

[root@linuxmaster1poc

~]#

mco

package

status

facter

*

[

============================================================>

]

3

/

3

linux58poc:

facter-1.7.3-1.el5.x86_64

linux64poc:

facter-1.7.3-1.el6.x86_64

linux57poc:

facter-1.7.3-1.el5.x86_64

Summary

of

Arch:

x86_64

=

3

Summary

of

Ensure:

1.7.3-1.el5

=

2

1.7.3-1.el6

=

1

Finished

processing

3

/

3

hosts

in

124.99

ms更多的功能可通過以下方式查看:[root@linuxmaster1poc

~]#

mco

puppet

-h

Schedule

runs,

enable,

disable

and

interrogate

the

Puppet

Agent

Usage:

mco

puppet

[OPTIONS]

[FILTERS]

<ACTION>

[CONCURRENCY|MESSAGE]

Usage:

mco

puppet

<count|enable|status|summary>

Usage:

mco

puppet

disable

[message]

Usage:

mco

puppet

runonce

[PUPPET

OPTIONS]

Usage:

mco

puppet

resource

type

name

property1=value

property2=value

Usage:

mco

puppet

runall

[--rerun

SECONDS]

[PUPPET

OPTIONS]

The

ACTION

can

be

one

of

the

following:

count

-

return

a

total

count

of

running,

enabled,

and

disabled

nodes

enable

-

enable

the

Puppet

Agent

if

it

was

previously

disabled

disable

-

disable

the

Puppet

Agent

preventing

catalog

from

being

applied

resource

-

manage

individual

resources

using

the

Puppet

Type

(RAL)

system

runall

-

invoke

a

puppet

run

on

matching

nodes,

making

sure

to

only

run

CONCURRENCY

nodes

at

a

time

runonce

-

invoke

a

Puppet

run

on

matching

nodes

status

-

shows

a

short

summary

about

each

Puppet

Agent

status

summary

-

shows

resource

and

run

time

summaries

--force

Bypass

splay

options

when

running

--server

SERVER

Connect

to

a

specific

server

or

port

--tags,

--tag

TAG

Restrict

the

run

to

specific

tags

--noop

Do

a

noop

run

--no-noop

Do

a

run

with

noop

disabled

--environment

ENVIRONMENT

Place

the

node

in

a

specific

environment

for

this

run

--splay

Splay

the

run

by

up

to

splaylimit

seconds

--no-splay

Do

a

run

with

splay

disabled

--splaylimit

SECONDS

Maximum

splay

time

for

this

run

if

splay

is

set

--ignoreschedules

Disable

schedule

processing

--rerun

SECONDS

When

performing

runall

do

so

repeatedly

with

a

minimum

run

time

of

SECONDS

--np,

--no-progress

Do

not

show

the

progress

bar

-1,

--one

Send

request

to

only

one

discovered

nodes

--batch

SIZE

Do

requests

in

batches

--batch-sleep

SECONDS

Sleep

time

between

batches

--limit-seed

NUMBER

Seed

value

for

deterministic

random

batching

--limit-nodes,

--ln,

--limit

COUNT

Send

request

to

only

a

subset

of

nodes,

can

be

a

percentage

-j,

--json

Produce

JSON

output

--display

MODE

Influence

how

results

are

displayed.

One

of

ok,

all

or

failed

-c,

--config

FILE

Load

configuratuion

from

file

rather

than

default

-v,

--verbose

Be

verbose

-h,

--help

Display

this

screen

Common

Options

-T,

--target

COLLECTIVE

Target

messages

to

a

specific

sub

collective

--dt,

--discovery-timeout

SECONDS

Timeout

for

doing

discovery

-t,

--timeout

SECONDS

Timeout

for

calling

remote

agents

-q,

--quiet

Do

not

be

verbose

--ttl

TTL

Set

the

message

validity

period

--reply-to

TARGET

Set

a

custom

target

for

replies

--dm,

--disc-method

METHOD

Which

discovery

method

to

use

--do,

--disc-option

OPTION

Options

to

pass

to

the

discovery

method

--nodes

FILE

List

of

nodes

to

address

Host

Filters

-W,

--with

FILTER

Combined

classes

and

facts

filter

-S,

--select

FILTER

Compound

filter

combining

facts

and

classes

-F,

--wf,

--with-fact

fact=val

Match

hosts

with

a

certain

fact

-C,

--wc,

--with-class

CLASS

Match

hosts

with

a

certain

config

management

class

-A,

--wa,

--with-agent

AGENT

Match

hosts

with

a

certain

agent

-I,

--wi,

--with-identity

IDENT

Match

hosts

with

a

certain

configured

identity

The

Marionette

Collective

2.2.42、組合mcollective各種plugins完成各種任務(wù)組合2.1、停止操作系統(tǒng)為RHEL5.x服務(wù)器的crond任務(wù)先查看5.x系統(tǒng)crond的狀態(tài),使用插件service、facts[root@linuxmaster1poc

~]#

mco

service

crond

status

-F

operatingsystemmajrelease=5

*

[

============================================================>

]

2

/

2

linux57poc:

running

linux58poc:

running

Summary

of

Service

Status:

running

=

2

Finished

processing

2

/

2

hosts

in

184.79

ms然后通過service插件停止服務(wù),使用插件service、facts[root@linuxmaster1poc

~]#

mco

service

crond

stop

-F

operatingsystemmajrelease=5

*

[

============================================================>

]

2

/

2

Summary

of

Service

Status:

stopped

=

2

Finished

processing

2

/

2

hosts

in

914.76

ms再次查看過濾的主機(jī)crond服務(wù)是否被停掉,使用插件service、facts[root@linuxmaster1poc

~]#

mco

service

crond

status

-F

operatingsystemmajrelease=5

*

[

============================================================>

]

2

/

2

linux57poc:

stopped

linux58poc:

stopped

Summary

of

Service

Status:

stopped

=

2

Finished

processing

2

/

2

hosts

in

125.87

ms也可以通過shell插件實(shí)現(xiàn),使用到插件為shell、service、facts[root@linuxmaster1poc

~]#

mco

shell

"service

crond

status"

-F

operatingsystemmajrelease=5

Discovering

hosts

using

the

mc

method

for

2

second(s)

2

Host:

linux57poc

Statuscode:

3

Output:

crond

is

stopped

Host:

linux58poc

Statuscode:

3

Output:

crond

is

stopped2.2、使用mco對自定義fact_apply4=app的主機(jī)做一次變更,要求環(huán)境為testing,模式為noop首先查看下那些主機(jī)具備有這個(gè)自定義fact,使用的插件為find、inventory[root@linuxmaster1poc

~]#

for

i

in

`mco

find`

;

do

echo

$i;

mco

inventory

$i

|

grep

fact_apply4;

done

linux58poc

fact_apply4

=>

app

linux57poc

linux64poc

fact_apply4

=>

app其次按要求做變更即可,使用到的插件為puppet,facts[root@linuxmaster1poc

~]#

mco

puppet

-v

runonce

--environment=testing

--noop

-F

fact_apply4=app

Discovering

hosts

using

the

mc

method

for

2

second(s)

2

*

[

============================================================>

]

2

/

2

linux64poc

:

OK

{:summary=>

"Started

a

background

Puppet

run

using

the

'puppet

agent

--onetime

--daemonize

--color=false

--splay

--splaylimit

30

--noop

--environment

testing'

command"}

linux58poc

:

OK

{:summary=>

"Started

a

background

Puppet

run

using

the

'puppet

agent

--onetime

--daemonize

--color=false

--splay

--splaylimit

30

--noop

--environment

testing'

command"}

rpc

stats

Nodes:

2

/

2

Pass

/

Fail:

2

/

0

Start

Time:

Fri

Dec

13

09:10:50

+0800

2013

Discovery

Time:

2003.32ms

Agent

Time:

884.34ms

Total

Time:

2887.67ms變更完成后,迅速查看節(jié)點(diǎn)運(yùn)行情況,使用到的插件為puppet

[root@linuxmaster1poc~]#mcopuppetstatus

*

[

============================================================>

]

3

/

3

linux64poc:

Currently

idling;

last

completed

run

54

seconds

ago

linux58poc:

Currently

applying

a

catalog;

last

completed

run

1

minutes

12

seconds

ago

linux57poc:

Currently

stopped;

last

completed

run

22

minutes

57

seconds

ago

Summary

of

Applying:

false

=

2

true

=

1

Summary

of

Daemon

Running:

running

=

2

stopped

=

1

Summary

of

Enabled:

enabled

=

3

Summary

of

Idling:

false

=

2

true

=

1

Summary

of

Status:

idling

=

1

stopped

=

1

applying

a

catalog

=

1

Finished

processing

3

/

3

hosts

in

263.72

ms3、遠(yuǎn)程改所有系統(tǒng)為RHEL6.4主機(jī)root的密碼,使用到的插件為shell,facts[root@linuxmaster1poc

~]#

mco

shell

"echo

redhat

|

passwd

root

--stdin"

-F

operatingsystemrelease=6.4

Discovering

hosts

using

the

mc

method

for

2

second(s)

1

Host:

linux64poc

Statuscode:

0

Output:

Changing

password

for

user

root.

passwd:

all

authentication

tokens

updated

successfully.4、查看所有節(jié)點(diǎn)puppet和facter安裝包的版本信息,使用到的插件為package[root@linuxmaster1poc

~]#

mco

package

status

puppet

*

[

============================================================>

]

3

/

3

linux64poc:

puppet-2.7.23-1.el6.noarch

linux57poc:

puppet-2.7.23-1.el5.noarch

linux58poc:

puppet-2.7.23-1.el5.noarch

Summary

of

Arch:

noarch

=

3

Summary

of

Ensure:

2.7.23-1.el5

=

2

2.7.23-1.el6

=

1

Finished

processing

3

/

3

hosts

in

635.21

ms

[root@linuxmaster1poc

~]#

mco

package

status

facter

*

[

============================================================>

]

3

/

3

linux58poc:

facter-1.7.3-1.el5.x86_64

linux64poc:

facter-1.7.3-1.el6.x86_64

linux57poc:

facter-1.7.3-1.el5.x86_64

Summary

of

Arch:

x86_64

=

3

Summary

of

Ensure:

1.7.3-1.el5

=

2

1.7.3-1.el6

=

1

Finished

processing

3

/

3

hosts

in

124.99

ms更多的功能可通過以下方式查看:[root@linuxmaster1poc

~]#

mco

puppet

-h

Schedule

runs,

enable,

disable

and

interrogate

the

Puppet

Agent

Usage:

mco

puppet

[OPTIONS]

[FILTERS]

<ACTION>

[CONCURRENCY|MESSAGE]

Usage:

mco

puppet

<count|enable|status|summary>

Usage:

mco

puppet

disable

[message]

Usage:

mco

puppet

runonce

[PUPPET

OPTIONS]

Usage:

mco

puppet

resource

type

name

property1=value

property2=value

Usage:

mco

puppet

runall

[--rerun

SECONDS]

[PUPPET

OPTIONS]

The

ACTION

can

be

one

of

the

following:

count

-

return

a

total

count

of

running,

enabled,

and

disabled

nodes

enable

-

enable

the

Puppet

Agent

if

it

was

previously

disabled

disable

-

disable

the

Puppet

Agent

preventing

catalog

from

being

applied

resource

-

manage

individual

resources

using

the

Puppet

Type

(RAL)

system

runall

-

invoke

a

puppet

run

on

matching

nodes,

making

sure

to

only

run

CONCURRENCY

nodes

at

a

time

runonce

-

invoke

a

Puppet

run

on

matching

nodes

status

-

shows

a

short

summary

about

each

Puppet

Agent

status

summary

-

shows

resource

and

run

time

summaries

--force

Bypass

s

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論