{"id":1179,"date":"2009-11-30T00:18:12","date_gmt":"2009-11-29T23:18:12","guid":{"rendered":"http:\/\/www.devco.net\/?p=1179"},"modified":"2010-08-17T12:28:56","modified_gmt":"2010-08-17T11:28:56","slug":"managing_puppetd_with_mcollective","status":"publish","type":"post","link":"https:\/\/www.devco.net\/archives\/2009\/11\/30\/managing_puppetd_with_mcollective.php","title":{"rendered":"Managing puppetd with mcollective"},"content":{"rendered":"

It’s typical during maintenance windows that you would want to disable puppet, do your work, enable again and do a run. Or perhaps you don’t run puppet all the time, you just want to kick it off during your maintenance window. Doing this with ssh for loops is slow and annoying, here’s a way to target large sums of machines for these actions using mcollective.<\/p>\n

Using mcollective<\/a>‘s discovery features and a suitable agent this is really easy, I’ve written such an agent and made it available on the mcollective-plugins site<\/a>. <\/p>\n

You can see below a sample session with it. In all of the examples below we’re constraining it to hosts with the roles::dev_server<\/em> puppet class using mcollective discovery. Not shown here is that you can get status as well as use the splay options provided by puppet, see the wiki page<\/a> for details on that.<\/p>\n

First we’ll make sure it’s enabled.<\/p>\n

<\/p>\n

\r\n$ mc-puppetd --with-class roles::dev_server enable\r\nDetermining the amount of hosts matching filter for 2 seconds .... 1\r\n\r\n.\r\n\r\nFinished processing 1 \/ 1 hosts in 9.81 ms\r\n<\/pre>\n

<\/code><\/p>\n

Now we’ll disable it<\/p>\n

<\/p>\n

\r\n$ mc-puppetd --with-class roles::dev_server disable\r\nDetermining the amount of hosts matching filter for 2 seconds .... 1\r\n\r\n.\r\n\r\nFinished processing 1 \/ 1 hosts in 3252.13 ms\r\n<\/pre>\n

<\/code><\/p>\n

We’ll attempt a runonce, this should fail because we just disabled the agent.<\/p>\n

<\/p>\n

\r\n$ mc-puppetd --with-class roles::dev_server runonce -v\r\nDetermining the amount of hosts matching filter for 2 seconds .... 1\r\n\r\ndev1.your.net                      status=false\r\n    Lock file exists                        \r\n\r\n\r\n---- puppetd agent stats ----\r\n           Nodes: 1 \/ 1\r\n      Start Time: Sun Nov 29 23:02:30 +0000 2009\r\n  Discovery Time: 2006.38ms\r\n      Agent Time: 47.62ms\r\n      Total Time: 2054.00ms\r\n<\/pre>\n

<\/code><\/p>\n

Let’s enable it and then try to run again.<\/p>\n

<\/p>\n

\r\n$ mc-puppetd --with-class roles::dev_server enable\r\nDetermining the amount of hosts matching filter for 2 seconds .... 1\r\n\r\n.\r\n\r\nFinished processing 1 \/ 1 hosts in 9.81 ms\r\n\r\n$ mc-puppetd --with-class roles::dev_server runonce\r\nDetermining the amount of hosts matching filter for 2 seconds .... 1\r\n\r\n.\r\n\r\nFinished processing 1 \/ 1 hosts in 2801.82 ms\r\n\r\n<\/pre>\n

<\/code><\/p>\n

I think this is a good way to orchestrate these type of maintenance window and I hope someone finds it useful.<\/p>\n","protected":false},"excerpt":{"rendered":"

It’s typical during maintenance windows that you would want to disable puppet, do your work, enable again and do a run. Or perhaps you don’t run puppet all the time, you just want to kick it off during your maintenance window. Doing this with ssh for loops is slow and annoying, here’s a way to […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","footnotes":""},"categories":[1],"tags":[121,78,21],"_links":{"self":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/1179"}],"collection":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/comments?post=1179"}],"version-history":[{"count":8,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/1179\/revisions"}],"predecessor-version":[{"id":1717,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/1179\/revisions\/1717"}],"wp:attachment":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/media?parent=1179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/categories?post=1179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/tags?post=1179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}