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)
def test_nodes_several(self): """Should configure several nodes""" runner.node('testnode1', 'testnode2') self.assertEquals(runner.env.hosts, ['testnode1', 'testnode2'])
def test_nodes_one(self): """Should configure one node""" runner.node('testnode1') self.assertEquals(runner.env.hosts, ['testnode1'])
def _bootstrap_node(self, host): lc.node(host.get_host_string())
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'])
def test_nodes_all(self): """Should configure all nodes when 'all' is given""" runner.node('all') self.assertEqual(runner.env.hosts, self.nodes)
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'])
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'])
def test_node_several(self): """Should configure several nodes""" runner.node('testnode1', 'testnode2') self.assertEqual(runner.env.hosts, ['testnode1', 'testnode2'])
def test_nodes_all(self): """Should configure all nodes""" runner.node('all') self.assertEquals(runner.env.hosts, ['testnode1', 'testnode2', 'testnode3.mydomain.com'])
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"])
def test_nodes_several(self): """Should configure several nodes""" runner.node("testnode1", "testnode2") self.assertEquals(runner.env.hosts, ["testnode1", "testnode2"])
def test_node_all(self): """Should configure all nodes when 'all' is given""" runner.node('all') self.assertEqual(runner.env.hosts, self.nodes)
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'])
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)