lita-puppet 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/lita/handlers/puppet.rb +42 -2
- data/lita-puppet.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 424717086cabdb4281ada12708aa42ff8f788bd7
|
4
|
+
data.tar.gz: 130a80847876000d53c6bffaf27111534b584bd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12041f29bf1fcb457e4e0222a2f5773186e31d63887e984e6cd2e7d709cd2d658bc8242712fe2407e848bc7c4b13b47e0efd621ce9c127f709d900b754bab877
|
7
|
+
data.tar.gz: ab24030d11f7ab7352bd07092389a2c2b6bd8d1162f390ed762e8840cbbb0afccdbbd7d2dffb29610a1ca656fbd8bfed1ac75c035ae6af8180ac353ad6d0a0c3
|
data/lib/lita/handlers/puppet.rb
CHANGED
@@ -11,7 +11,16 @@ module Lita
|
|
11
11
|
:r10k_deploy,
|
12
12
|
command: true,
|
13
13
|
help: {
|
14
|
-
"puppet r10k
|
14
|
+
"puppet r10k [env]" => "Deploy the latest puppet code on the puppet master via r10k, optionally specifying an environment."
|
15
|
+
}
|
16
|
+
)
|
17
|
+
|
18
|
+
route(
|
19
|
+
/(puppet|pp)(\s+agent)?\s+(run)(\s+on)?\s(\S+)/i,
|
20
|
+
:puppet_agent_run,
|
21
|
+
command: true,
|
22
|
+
help: {
|
23
|
+
"puppet agent run on <host>" => "Run the puppet agent on <host>."
|
15
24
|
}
|
16
25
|
)
|
17
26
|
|
@@ -46,12 +55,43 @@ module Lita
|
|
46
55
|
# build a reply
|
47
56
|
response.reply("#{username}, your r10k deployment is done!")
|
48
57
|
if ret
|
49
|
-
response.reply ret.
|
58
|
+
response.reply "/code " + ret.stderr.join("\n")
|
50
59
|
else
|
51
60
|
response.reply "But didn't seem to work... I think it may have timed out."
|
52
61
|
end
|
53
62
|
end
|
54
63
|
|
64
|
+
def puppet_agent_run(response)
|
65
|
+
host = response.matches[0][4]
|
66
|
+
user = config.ssh_user || 'lita'
|
67
|
+
username = response.user.name
|
68
|
+
|
69
|
+
response.reply("#{username}, I'll run puppet right away. Give me a sec and I'll let you know how it goes.")
|
70
|
+
|
71
|
+
ret = nil
|
72
|
+
|
73
|
+
Timeout::timeout(300) do
|
74
|
+
remote = Rye::Box.new(host, user: user)
|
75
|
+
remote.cd '/tmp'
|
76
|
+
|
77
|
+
# Need to use sudo from here on
|
78
|
+
remote.enable_sudo
|
79
|
+
|
80
|
+
# scary...
|
81
|
+
remote.disable_safe_mode
|
82
|
+
|
83
|
+
ret = remote.execute 'puppet agent -t'
|
84
|
+
remote.disconnect
|
85
|
+
end
|
86
|
+
|
87
|
+
# build a reply
|
88
|
+
if ret
|
89
|
+
response.reply "#{username}, that puppet run is complete! It exited with status #{ret.exit_status}."
|
90
|
+
else
|
91
|
+
response.reply "#{username}, your puppet run is done, but didn't seem to work... I think it may have timed out."
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
55
95
|
Lita.register_handler(self)
|
56
96
|
end
|
57
97
|
end
|
data/lita-puppet.gemspec
CHANGED