Exemplo n.º 1
0
 def test_run_ok(self):
     t = pyansible.Task([
         {
             'command': 'ls'
         },
     ])
     self.assertTrue(t.run())
     self.assertIsNone(t.runtime_errors)
Exemplo n.º 2
0
 def test_run_mock_ko(self):
     t = pyansible.Task({'command': 'ls'})
     t._tqm._stats.increment('failures', 'localhost')
     self.assertFalse(t.run())
Exemplo n.º 3
0
 def test_ssh_key(self):
     t = pyansible.Task({'command': 'ls'})
     t.ssh_key = 'ssh.key'
     self.assertIn('ssh.key', t._tqm._options.private_key_file)
Exemplo n.º 4
0
 def test_extra_vars(self):
     t = pyansible.Task({'command': 'ls'}, extra_vars={'toto': 'tata'})
     self.assertIn('vars', t.play)
     self.assertEquals({'toto': 'tata'}, t.play['vars'])
Exemplo n.º 5
0
 def test_no_ssh_key(self):
     t = pyansible.Task({'command': 'ls'})
     self.assertIsNone(t._tqm._options.private_key_file)
Exemplo n.º 6
0
 def test_wrong_vault_file(self):
     ex = AnsibleFileNotFound if pyansible.version_info < (
         2, 5) else AnsibleError
     with self.assertRaises(ex):
         pyansible.Task({'command': 'ls'}, vault_password_file='foobar')
Exemplo n.º 7
0
 def test_remote(self):
     t = pyansible.Task({'command': 'ls'}, host='192.168.0.1')
     self.assertEqual(t.play['connection'], 'smart')
     self.assertEqual(t.play['hosts'], 'all')
     self.assertIn('tasks', t.play)
Exemplo n.º 8
0
 def test_local(self):
     t = pyansible.Task({'command': 'ls'})
     self.assertEqual(t.play['connection'], 'local')
     self.assertEqual(t.play['hosts'], 'localhost')
     self.assertIn('tasks', t.play)
Exemplo n.º 9
0
 def test_name(self):
     t = pyansible.Task({'command': 'ls'})
     self.assertEqual(t.name, 'tasks')
Exemplo n.º 10
0
 def test_no_tasks(self):
     with self.assertRaises(TypeError):
         pyansible.Task()