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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7eb312914788d7ffa3d77b01222fefb998b9c372
4
- data.tar.gz: f4731fbe4b371cad8038aaedb3658101ec8cd9e7
3
+ metadata.gz: 424717086cabdb4281ada12708aa42ff8f788bd7
4
+ data.tar.gz: 130a80847876000d53c6bffaf27111534b584bd7
5
5
  SHA512:
6
- metadata.gz: ef51bf28d6598071ce4a63f57972c1e91dc82d413445990259aaf67a995529f2b53265cedff354fee2d48910569f5698a085009583e50f307d7ec0e82622a1ea
7
- data.tar.gz: 6c4109d07f7089d450a6027aad9c548069cb7780abd0cef3933439bfd3abd2dd16863b7bd085b0386e65b3685220f459c77b38e6ff843dc8c47c4e5f862e3bd6
6
+ metadata.gz: 12041f29bf1fcb457e4e0222a2f5773186e31d63887e984e6cd2e7d709cd2d658bc8242712fe2407e848bc7c4b13b47e0efd621ce9c127f709d900b754bab877
7
+ data.tar.gz: ab24030d11f7ab7352bd07092389a2c2b6bd8d1162f390ed762e8840cbbb0afccdbbd7d2dffb29610a1ca656fbd8bfed1ac75c035ae6af8180ac353ad6d0a0c3
@@ -11,7 +11,16 @@ module Lita
11
11
  :r10k_deploy,
12
12
  command: true,
13
13
  help: {
14
- "puppet r10k <env>" => "Deploy the latest puppet code on the puppet master via r10k, optionally specifying an environment."
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.stdout.join("\n")
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-puppet"
3
- spec.version = "0.1.4"
3
+ spec.version = "0.2.0"
4
4
  spec.authors = ["Jonathan Gnagy"]
5
5
  spec.email = ["jgnagy@knuedge.com"]
6
6
  spec.description = "Some basic Puppet interactions for Lita"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Gnagy