From 8f7fd8ba47687f6bf531e139e8dcb355cfcdfab3 Mon Sep 17 00:00:00 2001 From: Leos Stejskal Date: Tue, 7 Sep 2021 15:41:08 +0200 Subject: [PATCH] Add corresponding role for registration_commands module --- roles/registration_commands/README.md | 44 ++++++++++++++++++++++ roles/registration_commands/tasks/main.yml | 25 ++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 roles/registration_commands/README.md create mode 100644 roles/registration_commands/tasks/main.yml diff --git a/roles/registration_commands/README.md b/roles/registration_commands/README.md new file mode 100644 index 0000000000..8a69827363 --- /dev/null +++ b/roles/registration_commands/README.md @@ -0,0 +1,44 @@ +theforeman.foreman.registration_command +=========================== + +Generate Registration Command + +Role Variables +-------------- + +This role supports the [Common Role Variables](https://github.com/theforeman/foreman-ansible-modules/blob/develop/README.md#common-role-variables). + +- `foreman_organization`: Organization to register the host in. +- `foreman_location`: Location to register the host in. +- `foreman_hostgroup`: Host group to register the host in. +- `foreman_operatingsystem`: Operating System to register the host in, operating system must have a `host_init_config` template assigned. +- `foreman_smart_proxy`: Register host through smart proxy. +- `foreman_insecure`: Enable insecure argument for the initial curl. +- `foreman_setup_remote_execution`: Set `host_registration_remote_execution` parameter for the host. If it is set to `true`, SSH keys will be installed on the host. +- `foreman_setup_insights`: Set `host_registration_insights` parameter for the host. If it is set to `true`, insights client will be installed and registered on Red Hat family operating systems. +- `foreman_packages`: Packages to install on the host when registered, example: `pkg1 pkg2` +- `foreman_update_packages`: Update all packages on the host. +- `foreman_repo`: Repository URL / details, for example for Debian OS family: 'deb http://deb.example.com/ buster 1.0', for Red Hat OS family: 'http://yum.theforeman.org/client/latest/el8/x86_64/'. +- `foreman_repo_gpg_key_url`: URL of the GPG key for the repository. +- `foreman_jwt_expiration`: Expiration of the authorization token (in hours). +- `foreman_remote_execution_interface`: Identifier of the Host interface for Remote execution. +- `foreman_activation_keys`: Activation keys for subscription-manager client, required for CentOS and Red Hat Enterprise Linux. Required only if host group has no activation keys. +- `foreman_lifecycle_environment`: Lifecycle environment for the host. +- `foreman_ignore_subman_errors`: Ignore subscription-manager errors for `subscription-manager register` command. +- `foreman_force`: Clear any previous registration and run subscription-manager with --force. + +Example Playbooks +----------------- + +Generate registration command + +```yaml +- hosts: localhost + roles: + - role: theforeman.foreman.registration_commands + vars: + foreman_server_url: "https://foreman.example.com" + foreman_username: "admin" + foreman_password: "changeme" + foreman_organization: "Default Organization" +``` diff --git a/roles/registration_commands/tasks/main.yml b/roles/registration_commands/tasks/main.yml new file mode 100644 index 0000000000..c2f2e4a7cc --- /dev/null +++ b/roles/registration_commands/tasks/main.yml @@ -0,0 +1,25 @@ +--- +- name: 'Generate registration command' + theforeman.foreman.registration_command: + username: "{{ foreman_username | default(omit) }}" + password: "{{ foreman_password | default(omit) }}" + server_url: "{{ foreman_server_url | default(omit) }}" + validate_certs: "{{ foreman_validate_certs | default(omit) }}" + organization: "{{ foreman_organization | default(omit) }}" + location: "{{ foreman_location | default(omit) }}" + hostgroup: "{{ foreman_hostgroup | default(omit) }}" + operatingsystem: "{{ foreman_operatingsystem | default(omit) }}" + smart_proxy: "{{ foreman_smart_proxy | default(omit) }}" + insecure: "{{ foreman_insecure | default(omit) }}" + setup_remote_execution: "{{ foreman_setup_remote_execution | default(omit) }}" + setup_insights: "{{ foreman_setup_insights | default(omit) }}" + packages: "{{ foreman_packages | default(omit) }}" + update_packages: "{{ foreman_update_packages | default(omit) }}" + repo: "{{ foreman_repo | default(omit) }}" + repo_gpg_key_url: "{{ foreman_repo_gpg_key_url | default(omit) }}" + jwt_expiration: "{{ foreman_jwt_expiration | default(omit) }}" + remote_execution_interface: "{{ foreman_remote_execution_interface | default(omit) }}" + activation_keys: "{{ foreman_activation_keys | default(omit) }}" + lifecycle_environment: "{{ foreman_lifecycle_environment | default(omit) }}" + ignore_subman_errors: "{{ foreman_ignore_subman_errors | default(omit) }}" + force: "{{ foreman_force | default(omit) }}"