Class: PuppetPSSH::List
- Inherits:
-
BaseCommand
- Object
- Clamp::Command
- BaseCommand
- PuppetPSSH::List
- Defined in:
- lib/puppet-pssh.rb
Instance Method Summary collapse
Methods inherited from BaseCommand
#get_nodes, #master_url, #node_status
Instance Method Details
#execute ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/puppet-pssh.rb', line 134 def execute begin get_nodes(puppetmaster).each do |n| next unless n =~ /#{match}/ if all_facts? pp JSON.parse(Excon.get(master_url + "facts/#{n}").body) elsif fact value = JSON.parse( Excon.get(master_url + "facts/#{n}").body )['facts'][fact] || 'fact_not_found' puts n puts " #{fact.yellow}: " + value elsif with_facts facts = JSON.parse( Excon.get(master_url + "facts/#{n}").body )['facts'] keys = facts.keys with_facts.split(',').each do |f| if keys.include?(f) puts n break end end elsif status? puts n status = node_status(n) puts " #{'name:'.ljust(20).yellow} #{n}" if status['deactivated'] puts " #{'deactivated:'.ljust(20).yellow} " + "yes (#{status['deactivated']})" else puts " #{'deactivated:'.ljust(20).yellow} no" end puts " #{'catalog_timestamp:'.ljust(20).yellow} " + "#{status['catalog_timestamp']}" puts " #{'facts_timestamp:'.ljust(20).yellow} " + "#{status['facts_timestamp']}" else puts n end end rescue Exception => e Log.error e. Log.debug e.backtrace exit 1 end end |