Esempio n. 1
0
 def test_run_ok(self):
     t = pyansible.Task([
         {
             'command': 'ls'
         },
     ])
     self.assertTrue(t.run())
     self.assertIsNone(t.runtime_errors)
Esempio n. 2
0
 def test_run_mock_ko(self):
     t = pyansible.Task({'command': 'ls'})
     t._tqm._stats.increment('failures', 'localhost')
     self.assertFalse(t.run())
Esempio 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)
Esempio 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'])
Esempio n. 5
0
 def test_no_ssh_key(self):
     t = pyansible.Task({'command': 'ls'})
     self.assertIsNone(t._tqm._options.private_key_file)
Esempio 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')
Esempio 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)
Esempio 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)
Esempio n. 9
0
 def test_name(self):
     t = pyansible.Task({'command': 'ls'})
     self.assertEqual(t.name, 'tasks')
Esempio n. 10
0
 def test_no_tasks(self):
     with self.assertRaises(TypeError):
         pyansible.Task()