Exemplo n.º 1
0
def main():
    parser = OptionParser()
    parser.add_option("-u", "--username", default="root",
        help="username for new server, defaults to %default")
    parser.add_option("-p", "--password", dest="password",
        help="password for new server")
    parser.add_option("-H", "--hostname", dest="hostname",
        help="hostname or ip of new server")

    (options, args) = parser.parse_args()

    # begin hackery to load config file until littlechef gets fixed (04DEC2012)

    ### CHANGE THE ssh_config VALUE AS NEEDED ###
    ssh_config = "~/.ssh/chef.config"

    lc.env.use_ssh_config = True
    lc.env.ssh_config = _SSHConfig()
    lc.env.ssh_config_path = os.path.expanduser(ssh_config)

    lc.env.user = options.username
    lc.env.password = options.password
    lc.env.host_string = options.hostname
    lc.env.host = options.hostname
    lc.env.node_work_path = "/tmp/chef-solo"
    lc.env.follow_symlinks = False

    ### CHANGE THIS TO POINT TO WHERE YOU SAVED THE FILE ###
    lc.env.encrypted_data_bag_secret = "/etc/chef/data_bag_secret_key.txt"

    # We need the ohai plugins installed before running Chef
    lc.plugin("install_omnibus_chef")
    lc.node(options.hostname)
Exemplo n.º 2
0
 def test_nodes_several(self):
     """Should configure several nodes"""
     runner.node('testnode1', 'testnode2')
     self.assertEquals(runner.env.hosts, ['testnode1', 'testnode2'])
Exemplo n.º 3
0
 def test_nodes_one(self):
     """Should configure one node"""
     runner.node('testnode1')
     self.assertEquals(runner.env.hosts, ['testnode1'])
Exemplo n.º 4
0
 def _bootstrap_node(self, host):
     lc.node(host.get_host_string())
Exemplo n.º 5
0
 def test_nodes_one(self):
     """Should configure one node when an existing node name is given"""
     runner.node('testnode1')
     self.assertEqual(runner.env.hosts, ['testnode1'])
Exemplo n.º 6
0
 def test_nodes_all(self):
     """Should configure all nodes when 'all' is given"""
     runner.node('all')
     self.assertEqual(runner.env.hosts, self.nodes)
Exemplo n.º 7
0
 def test_node_all_in_env(self):
     """Should configure all nodes in a given environment when 'all' is
     given and evironment is set"""
     runner.env.chef_environment = "staging"
     runner.node('all')
     self.assertEqual(runner.env.hosts, ['testnode2'])
Exemplo n.º 8
0
 def test_node_one(self):
     """Should configure one node when an existing node name is given"""
     runner.node('testnode1')
     self.assertEqual(runner.env.hosts, ['testnode1'])
Exemplo n.º 9
0
 def test_node_several(self):
     """Should configure several nodes"""
     runner.node('testnode1', 'testnode2')
     self.assertEqual(runner.env.hosts, ['testnode1', 'testnode2'])
Exemplo n.º 10
0
 def test_nodes_all(self):
     """Should configure all nodes"""
     runner.node('all')
     self.assertEquals(runner.env.hosts,
                       ['testnode1', 'testnode2', 'testnode3.mydomain.com'])
Exemplo n.º 11
0
 def _bootstrap_node(self, host):
     lc.node(host.get_host_string())
Exemplo n.º 12
0
 def test_nodes_one(self):
     """Should configure one node"""
     runner.node('testnode1')
     self.assertEquals(runner.env.hosts, ['testnode1'])
Exemplo n.º 13
0
 def test_nodes_all(self):
     """Should configure all nodes when 'all' is given"""
     runner.node("all")
     self.assertEquals(runner.env.hosts, ["testnode1", "testnode2", "testnode3.mydomain.com", "testnode4"])
Exemplo n.º 14
0
 def test_nodes_several(self):
     """Should configure several nodes"""
     runner.node("testnode1", "testnode2")
     self.assertEquals(runner.env.hosts, ["testnode1", "testnode2"])
Exemplo n.º 15
0
 def test_nodes_all(self):
     """Should configure all nodes"""
     runner.node('all')
     self.assertEquals(runner.env.hosts,
         ['testnode1', 'testnode2', 'testnode3.mydomain.com'])
Exemplo n.º 16
0
 def test_node_all(self):
     """Should configure all nodes when 'all' is given"""
     runner.node('all')
     self.assertEqual(runner.env.hosts, self.nodes)
Exemplo n.º 17
0
 def test_nodes_all_in_env(self):
     """Should configure all nodes in a given environment"""
     runner.env.chef_environment = "staging"
     runner.node('all')
     self.assertEquals(runner.env.hosts, ['testnode2'])
Exemplo n.º 18
0
 def test_nodes_all(self):
     """Should configure all nodes when 'all' is given"""
     runner.node('all')
     expected = ['testnode1', 'testnode2', 'testnode3.mydomain.com', 'testnode4']
     self.assertEquals(runner.env.hosts, expected)