Class: Formatron::Chef::SSH
- Inherits:
-
Object
- Object
- Formatron::Chef::SSH
- Defined in:
- lib/formatron/chef/ssh.rb
Overview
Perform commands on chef nodes over SSH
Constant Summary collapse
- SSH_USER =
'ubuntu'
Instance Method Summary collapse
- #bootstrapped?(hostname:, bastion_hostname:) ⇒ Boolean
-
#initialize(keys:) ⇒ SSH
constructor
A new instance of SSH.
- #run_chef_client(hostname:, bastion_hostname:) ⇒ Object
Constructor Details
#initialize(keys:) ⇒ SSH
Returns a new instance of SSH.
9 10 11 |
# File 'lib/formatron/chef/ssh.rb', line 9 def initialize(keys:) @keys = keys end |
Instance Method Details
#bootstrapped?(hostname:, bastion_hostname:) ⇒ Boolean
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/formatron/chef/ssh.rb', line 26 def bootstrapped?(hostname:, bastion_hostname:) Formatron::Util::SSH.exec( hostname: hostname, bastion_hostname: bastion_hostname, user: SSH_USER, key: @keys.ec2_key, command: '[ -f /etc/chef/client.pem ]' ) true rescue false end |
#run_chef_client(hostname:, bastion_hostname:) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/formatron/chef/ssh.rb', line 13 def run_chef_client(hostname:, bastion_hostname:) # use the first-boot.json to ensure the runlist is correct # if the node fails to converge the first time (in which case # the server will show an empty run list for the node) Formatron::Util::SSH.exec( hostname: hostname, bastion_hostname: bastion_hostname, user: SSH_USER, key: @keys.ec2_key, command: 'sudo chef-client -j /etc/chef/first-boot.json' ) end |