- Manage firewall rules with firewalld.
required: false
default: true
+ registry_url:
+ description:
+ - URL for custom registry.
+ required: false
+ registry_username:
+ description:
+ - Username for custom registry.
+ required: false
+ registry_password:
+ description:
+ - Password for custom registry.
+ required: false
+ registry_json:
+ description:
+ - JSON file with custom registry login info (URL, username, password).
+ required: false
author:
- Dimitri Savineau <dsavinea@redhat.com>
'''
dashboard_password=dict(type='str', required=False, no_log=True),
monitoring=dict(type='bool', required=False, default=True),
firewalld=dict(type='bool', required=False, default=True),
+ registry_url=dict(type='str', require=False),
+ registry_username=dict(type='str', require=False),
+ registry_password=dict(type='str', require=False, no_log=True),
+ registry_json=dict(type='path', require=False),
),
supports_check_mode=True,
+ mutually_exclusive=[
+ ('registry_json', 'registry_url'),
+ ('registry_json', 'registry_username'),
+ ('registry_json', 'registry_password'),
+ ],
+ required_together=[
+ ('registry_url', 'registry_username', 'registry_password')
+ ],
)
mon_ip = module.params.get('mon_ip')
dashboard_password = module.params.get('dashboard_password')
monitoring = module.params.get('monitoring')
firewalld = module.params.get('firewalld')
+ registry_url = module.params.get('registry_url')
+ registry_username = module.params.get('registry_username')
+ registry_password = module.params.get('registry_password')
+ registry_json = module.params.get('registry_json')
startd = datetime.datetime.now()
if not firewalld:
cmd.append('--skip-firewalld')
+ if registry_url and registry_username and registry_password:
+ cmd.extend(['--registry-url', registry_url,
+ '--registry-username', registry_username,
+ '--registry-password', registry_password])
+
+ if registry_json:
+ cmd.extend(['--registry-json', registry_json])
+
if module.check_mode:
exit_module(
module=module,
fake_fsid = '0f1e0605-db0b-485c-b366-bd8abaa83f3b'
fake_image = 'quay.ceph.io/ceph/daemon-base:latest-master-devel'
fake_ip = '192.168.42.1'
+fake_registry = 'quay.ceph.io'
+fake_registry_user = 'foo'
+fake_registry_pass = 'bar'
+fake_registry_json = 'registry.json'
class TestCephadmBootstrapModule(object):
assert result['changed']
assert result['cmd'] == ['cephadm', 'bootstrap', '--mon-ip', fake_ip, '--skip-firewalld']
assert result['rc'] == 0
+
+ @patch('ansible.module_utils.basic.AnsibleModule.exit_json')
+ @patch('ansible.module_utils.basic.AnsibleModule.run_command')
+ def test_with_registry_credentials(self, m_run_command, m_exit_json):
+ ca_test_common.set_module_args({
+ 'mon_ip': fake_ip,
+ 'registry_url': fake_registry,
+ 'registry_username': fake_registry_user,
+ 'registry_password': fake_registry_pass
+ })
+ m_exit_json.side_effect = ca_test_common.exit_json
+ stdout = ''
+ stderr = ''
+ rc = 0
+ m_run_command.return_value = rc, stdout, stderr
+
+ with pytest.raises(ca_test_common.AnsibleExitJson) as result:
+ cephadm_bootstrap.main()
+
+ result = result.value.args[0]
+ assert result['changed']
+ assert result['cmd'] == ['cephadm', 'bootstrap', '--mon-ip', fake_ip,
+ '--registry-url', fake_registry,
+ '--registry-username', fake_registry_user,
+ '--registry-password', fake_registry_pass]
+ assert result['rc'] == 0
+
+ @patch('ansible.module_utils.basic.AnsibleModule.exit_json')
+ @patch('ansible.module_utils.basic.AnsibleModule.run_command')
+ def test_with_registry_json_file(self, m_run_command, m_exit_json):
+ ca_test_common.set_module_args({
+ 'mon_ip': fake_ip,
+ 'registry_json': fake_registry_json
+ })
+ m_exit_json.side_effect = ca_test_common.exit_json
+ stdout = ''
+ stderr = ''
+ rc = 0
+ m_run_command.return_value = rc, stdout, stderr
+
+ with pytest.raises(ca_test_common.AnsibleExitJson) as result:
+ cephadm_bootstrap.main()
+
+ result = result.value.args[0]
+ assert result['changed']
+ assert result['cmd'] == ['cephadm', 'bootstrap', '--mon-ip', fake_ip,
+ '--registry-json', fake_registry_json]
+ assert result['rc'] == 0