Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an optional parameter to bypass FQDN check on the name field. #65

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions plugins/modules/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
- Fully Qualified Domain Name of host
required: true
type: str
allow_short_name:
description:
- If present and true, bypass the FQDN check on name parameter.
- Workaround for https://access.redhat.com/solutions/6279971
required: false
type: bool
hostgroup:
description:
- Title of related hostgroup
Expand Down Expand Up @@ -435,6 +441,9 @@ class ForemanHostModule(HostMixin, ForemanEntityAnsibleModule):

def main():
module = ForemanHostModule(
argument_spec=dict(
allow_short_name=dict(type='bool')
),
foreman_spec=dict(
name=dict(required=True),
hostgroup=dict(type='entity'),
Expand Down Expand Up @@ -463,8 +472,9 @@ def main():
)

# additional param validation
if '.' not in module.foreman_params['name']:
module.fail_json(msg="The hostname must be FQDN")
if not ('allow_short_name' in module.foreman_params and module.foreman_params['allow_short_name']):
if '.' not in module.foreman_params['name']:
module.fail_json(msg="The hostname must be FQDN")

if not module.desired_absent:
if 'build' in module.foreman_params and module.foreman_params['build']:
Expand Down