lita-puppet 2.1.4 → 2.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d80423ebb3746f0fda22ff43b2f93086bbc295ca
4
- data.tar.gz: c8f55e2beeffe1cfe1e29d99d6c31d006894fa49
3
+ metadata.gz: 8becf5247bbd3296019d1ee1940b856fbffc0ab8
4
+ data.tar.gz: 2f53802c6f4505aa8a48071bdc2756c967630a56
5
5
  SHA512:
6
- metadata.gz: 15fce99d528e4dfc3665481ddf0786debc70c52421a0b24bb00562bc58f446d32b12afb980543ca5277ee4df22c71770dd98700409db839ab696edb86f0cc42b
7
- data.tar.gz: da28f2632ec6ebb15f61d8dba2981068193c24a67d707507e6aa6dba9a4226b0a9fa957ab5afe8ece0c2d638fb9cfbca07e0979bec95b7c6ac9a52df5ee82a85
6
+ metadata.gz: 2cadbf6b61bd758d6c92769eb9d6f0e4ca592649dd247b96cdcf54913471978d6303e62e1c6684698c20cacf1558b865c104859e49f6e0a2bd686a27261501d1
7
+ data.tar.gz: ee73cac7096ee78f7c3f8ec00baa925a1e93097e6db7aba678149d67206dcf1beecdb9fb38e1b37eb32e9cfb0abdeaea87b4544b84d19681cdf7d82b5f0388b5
@@ -10,13 +10,13 @@ Metrics/LineLength:
10
10
  Max: 100
11
11
 
12
12
  Metrics/AbcSize:
13
- Max: 22
13
+ Max: 23
14
14
 
15
15
  Metrics/MethodLength:
16
16
  Max: 25
17
17
 
18
18
  Metrics/ClassLength:
19
- Max: 165
19
+ Max: 175
20
20
 
21
21
  Metrics/BlockLength:
22
22
  Max: 30
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.5
4
- - 2.3.1
4
+ - 2.3.4
5
5
  - 2.4.1
6
6
  services:
7
7
  - redis-server
@@ -1,6 +1,7 @@
1
1
  require 'lita'
2
2
  require 'rye'
3
3
  require 'timeout'
4
+ require 'resolv'
4
5
  require 'puppetdb'
5
6
 
6
7
  Lita.load_locales Dir[File.expand_path(
@@ -87,8 +87,18 @@ module Lita
87
87
  def puppet_agent_run(response)
88
88
  host = response.matches[0][4]
89
89
 
90
- response.reply_with_mention(t('replies.puppet_agent_run.working'))
90
+ resolvable = begin
91
+ Resolv.getaddress(host)
92
+ rescue Resolv::ResolvError
93
+ false
94
+ end
91
95
 
96
+ unless resolvable
97
+ response.reply_with_mention(t('replies.puppet_agent_run.dns_failure', machine: host))
98
+ return false
99
+ end
100
+
101
+ response.reply_with_mention(t('replies.puppet_agent_run.working'))
92
102
  result = simple_ssh_command(host, config.ssh_user, agent_command)
93
103
 
94
104
  # build a reply
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-puppet'
3
- spec.version = '2.1.4'
3
+ spec.version = '2.1.5'
4
4
  spec.authors = ['Daniel Schaaff', 'Jonathan Gnagy'].sort
5
5
  spec.email = ['jgnagy@knuedge.com']
6
6
  spec.description = 'Some basic Puppet interactions for Lita'
@@ -32,6 +32,7 @@ en:
32
32
  puppet_agent_run:
33
33
  working: "I'll run puppet right away. Give me a sec and I'll let you know how it goes."
34
34
  failure: "your puppet run is done, but didn't seem to work... I think it may have timed out."
35
+ dns_failure: "I couldn't find a machine called '%{machine}'."
35
36
  success: "that puppet run is complete! It exited with status %{status}."
36
37
  node_profiles:
37
38
  notconf: "I would do that, but I don't know how to connect to PuppetDB. Edit my config and add `config.handlers.puppet.puppetdb_url`."
@@ -112,15 +112,22 @@ describe Lita::Handlers::Puppet, lita_handler: true do
112
112
  before do
113
113
  robot.auth.add_user_to_group!(lita_user, :puppet_admins)
114
114
  end
115
- it 'should run a puppet agent' do
115
+
116
+ it 'notifies users when server names are not resolvable' do
116
117
  allow(Rye::Box).to receive(:new).and_return(rye_box)
117
118
  send_command('puppet agent run on server.name', as: lita_user)
119
+ expect(replies[-1]).to eq('I couldn\'t find a machine called \'server.name\'.')
120
+ end
121
+
122
+ it 'should run a puppet agent' do
123
+ allow(Rye::Box).to receive(:new).and_return(rye_box)
124
+ send_command('puppet agent run on localhost', as: lita_user)
118
125
  expect(replies[-2]).to eq('that puppet run is complete! It exited with status 0.')
119
126
  end
120
127
 
121
128
  it 'should truncate long results' do
122
129
  allow(Rye::Box).to receive(:new).and_return(rye_box)
123
- send_command('puppet agent run on server.name', as: lita_user)
130
+ send_command('puppet agent run on localhost', as: lita_user)
124
131
  expect(replies[-1].lines.last).to eq('... truncated to 50 lines')
125
132
  expect(replies[-1].lines.size).to eq(51)
126
133
  end
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: 2.1.4
4
+ version: 2.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Schaaff
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-06-13 00:00:00.000000000 Z
12
+ date: 2017-06-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: lita