Blame README-host.md

Packit 8cb997
Host module
Packit 8cb997
===========
Packit 8cb997
Packit 8cb997
Description
Packit 8cb997
-----------
Packit 8cb997
Packit 8cb997
The host module allows to ensure presence, absence and disablement of hosts.
Packit 8cb997
Packit 8cb997
The host module is as compatible as possible to the Ansible upstream `ipa_host` module, but additionally offers to disable hosts.
Packit 8cb997
Packit 8cb997
Packit 8cb997
Features
Packit 8cb997
--------
Packit 8cb997
* Host management
Packit 8cb997
Packit 8cb997
Packit 8cb997
Supported FreeIPA Versions
Packit 8cb997
--------------------------
Packit 8cb997
Packit 8cb997
FreeIPA versions 4.4.0 and up are supported by the ipahost module.
Packit 8cb997
Packit 8cb997
Packit 8cb997
Requirements
Packit 8cb997
------------
Packit 8cb997
Packit 8cb997
**Controller**
Packit 8cb997
* Ansible version: 2.8+
Packit 8cb997
Packit 8cb997
**Node**
Packit 8cb997
* Supported FreeIPA version (see above)
Packit 8cb997
Packit 8cb997
Packit 8cb997
Usage
Packit 8cb997
=====
Packit 8cb997
Packit 8cb997
Example inventory file
Packit 8cb997
Packit 8cb997
```ini
Packit 8cb997
[ipaserver]
Packit 8cb997
ipaserver.test.local
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
Packit 8cb997
Example playbook to ensure host presence:
Packit 8cb997
Packit 8cb997
```yaml
Packit 8cb997
---
Packit 8cb997
- name: Playbook to handle hosts
Packit 8cb997
  hosts: ipaserver
Packit 8cb997
  become: true
Packit 8cb997
Packit 8cb997
  tasks:
Packit 8cb997
  # Ensure host is present
Packit 8cb997
  - ipahost:
Packit 8cb997
      ipaadmin_password: MyPassword123
Packit 8cb997
      name: host01.example.com
Packit 8cb997
      description: Example host
Packit 8cb997
      ip_address: 192.168.0.123
Packit 8cb997
      locality: Lab
Packit 8cb997
      ns_host_location: Lab
Packit 8cb997
      ns_os_version: CentOS 7
Packit 8cb997
      ns_hardware_platform: Lenovo T61
Packit 8cb997
      mac_address:
Packit 8cb997
      - "08:00:27:E3:B1:2D"
Packit 8cb997
      - "52:54:00:BD:97:1E"
Packit 8cb997
      state: present
Packit 8cb997
```
Packit e64f81
Compared to `ipa host-add` command no IP address conflict check is done as the ipahost module supports to have several IPv4 and IPv6 addresses for a host.
Packit e64f81
Packit e64f81
Packit e64f81
Example playbook to ensure host presence with several IP addresses:
Packit e64f81
Packit e64f81
```yaml
Packit e64f81
---
Packit e64f81
- name: Playbook to handle hosts
Packit e64f81
  hosts: ipaserver
Packit e64f81
  become: true
Packit e64f81
Packit e64f81
  tasks:
Packit e64f81
  # Ensure host is present
Packit e64f81
  - ipahost:
Packit e64f81
      ipaadmin_password: MyPassword123
Packit e64f81
      name: host01.example.com
Packit e64f81
      description: Example host
Packit e64f81
      ip_address:
Packit e64f81
      - 192.168.0.123
Packit e64f81
      - 192.168.0.124
Packit e64f81
      - fe80::20c:29ff:fe02:a1b3
Packit e64f81
      - fe80::20c:29ff:fe02:a1b4
Packit e64f81
      locality: Lab
Packit e64f81
      ns_host_location: Lab
Packit e64f81
      ns_os_version: CentOS 7
Packit e64f81
      ns_hardware_platform: Lenovo T61
Packit e64f81
      mac_address:
Packit e64f81
      - "08:00:27:E3:B1:2D"
Packit e64f81
      - "52:54:00:BD:97:1E"
Packit e64f81
      state: present
Packit e64f81
```
Packit e64f81
Packit e64f81
Packit e64f81
Example playbook to ensure IP addresses are present for a host:
Packit e64f81
Packit e64f81
```yaml
Packit e64f81
---
Packit e64f81
- name: Playbook to handle hosts
Packit e64f81
  hosts: ipaserver
Packit e64f81
  become: true
Packit e64f81
Packit e64f81
  tasks:
Packit e64f81
  # Ensure host is present
Packit e64f81
  - ipahost:
Packit e64f81
      ipaadmin_password: MyPassword123
Packit e64f81
      name: host01.example.com
Packit e64f81
      ip_address:
Packit e64f81
      - 192.168.0.124
Packit e64f81
      - fe80::20c:29ff:fe02:a1b4
Packit e64f81
      action: member
Packit e64f81
      state: present
Packit e64f81
```
Packit e64f81
Packit e64f81
Packit e64f81
Example playbook to ensure IP addresses are absent for a host:
Packit e64f81
Packit e64f81
```yaml
Packit e64f81
---
Packit e64f81
- name: Playbook to handle hosts
Packit e64f81
  hosts: ipaserver
Packit e64f81
  become: true
Packit e64f81
Packit e64f81
  tasks:
Packit e64f81
  # Ensure host is present
Packit e64f81
  - ipahost:
Packit e64f81
      ipaadmin_password: MyPassword123
Packit e64f81
      name: host01.example.com
Packit e64f81
      ip_address:
Packit e64f81
      - 192.168.0.124
Packit e64f81
      - fe80::20c:29ff:fe02:a1b4
Packit e64f81
      action: member
Packit e64f81
      state: absent
Packit e64f81
```
Packit 8cb997
Packit 8cb997
Packit 8cb997
Example playbook to ensure host presence without DNS:
Packit 8cb997
Packit 8cb997
```yaml
Packit 8cb997
---
Packit 8cb997
- name: Playbook to handle hosts
Packit 8cb997
  hosts: ipaserver
Packit 8cb997
  become: true
Packit 8cb997
Packit 8cb997
  tasks:
Packit 8cb997
  # Ensure host is present without DNS
Packit 8cb997
  - ipahost:
Packit 8cb997
      ipaadmin_password: MyPassword123
Packit 8cb997
      name: host02.example.com
Packit 8cb997
      description: Example host
Packit 8cb997
      force: yes
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
Packit 8cb997
Example playbook to ensure host presence with a random password:
Packit 8cb997
Packit 8cb997
```yaml
Packit 8cb997
---
Packit 8cb997
- name: Ensure host with random password
Packit 8cb997
  hosts: ipaserver
Packit 8cb997
  become: true
Packit 8cb997
Packit 8cb997
  tasks:
Packit 8cb997
  - name: Host host01.example.com present with random password
Packit 8cb997
    ipahost:
Packit 8cb997
      ipaadmin_password: MyPassword123
Packit 8cb997
      name: host01.example.com
Packit 8cb997
      random: yes
Packit 8cb997
      force: yes
Packit 8cb997
    register: ipahost
Packit 8cb997
Packit 8cb997
  - name: Print generated random password
Packit 8cb997
    debug:
Packit 8cb997
      var: ipahost.host.randompassword
Packit 8cb997
```
Packit 8cb997
Please remember that the `force` tag will also force the generation of a new random password even if the host already exists and if `update_password` is limited to `on_create`.
Packit 8cb997
Packit 8cb997
Packit 8cb997
Example playbook to ensure presence of several hosts with a random password:
Packit 8cb997
Packit 8cb997
```yaml
Packit 8cb997
---
Packit 8cb997
- name: Ensure hosts with random password
Packit 8cb997
  hosts: ipaserver
Packit 8cb997
  become: true
Packit 8cb997
Packit 8cb997
  tasks:
Packit 8cb997
  - name: Hosts host01.example.com and host01.example.com present with random passwords
Packit 8cb997
    ipahost:
Packit 8cb997
      ipaadmin_password: MyPassword123
Packit 8cb997
      hosts:
Packit 8cb997
      - name: host01.example.com
Packit 8cb997
        random: yes
Packit 8cb997
        force: yes
Packit 8cb997
      - name: host02.example.com
Packit 8cb997
        random: yes
Packit 8cb997
        force: yes
Packit 8cb997
    register: ipahost
Packit 8cb997
Packit 8cb997
  - name: Print generated random password for host01.example.com
Packit 8cb997
    debug:
Packit 8cb997
      var: ipahost.host["host01.example.com"].randompassword
Packit 8cb997
Packit 8cb997
  - name: Print generated random password for host02.example.com
Packit 8cb997
    debug:
Packit 8cb997
      var: ipahost.host["host02.example.com"].randompassword
Packit 8cb997
```
Packit 8cb997
Please remember that the `force` tag will also force the generation of a new random password even if the host alreay exists and if `update_password` is limited to `on_create`.
Packit 8cb997
Packit 8cb997
Packit 8cb997
Example playbook to ensure presence of host member principal:
Packit 8cb997
Packit 8cb997
```yaml
Packit 8cb997
---
Packit 8cb997
- name: Host present with principal
Packit 8cb997
  hosts: ipaserver
Packit 8cb997
  become: true
Packit 8cb997
Packit 8cb997
  tasks:
Packit 8cb997
  - name: Host host01.example.com present with principals host/testhost01.example.com and host/myhost01.example.com
Packit 8cb997
    ipahost:
Packit 8cb997
      ipaadmin_password: MyPassword123
Packit 8cb997
      name: host01.example.com
Packit 8cb997
      principal:
Packit 8cb997
      - host/testhost01.example.com
Packit 8cb997
      - host/myhost01.example.com
Packit 8cb997
      action: member
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
Packit 8cb997
Example playbook to ensure presence of host member certificate:
Packit 8cb997
Packit 8cb997
```yaml
Packit 8cb997
- name: Host present with certificate
Packit 8cb997
  hosts: ipaserver
Packit 8cb997
  become: true
Packit 8cb997
Packit 8cb997
  tasks:
Packit 8cb997
  - name: Host host01.example.com present with certificate
Packit 8cb997
    ipahost:
Packit 8cb997
      ipaadmin_password: MyPassword123
Packit 8cb997
      name: host01.example.com
Packit 8cb997
      certificate:
Packit 8cb997
      - MIIC/zCCAeegAwIBAg...
Packit 8cb997
      action: member
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
Packit 8cb997
Example playbook to ensure presence of member managedby_host for serveral hosts:
Packit 8cb997
Packit 8cb997
```yaml
Packit 8cb997
---
Packit 8cb997
- name: Host present with managedby_host
Packit 8cb997
  hosts: ipaserver
Packit 8cb997
  become: true
Packit 8cb997
Packit 8cb997
  tasks:
Packit 8cb997
    ipahost:
Packit 8cb997
      ipaadmin_password: MyPassword123
Packit 8cb997
      hosts:
Packit 8cb997
      - name: host01.exmaple.com
Packit 8cb997
        managedby_host: server.exmaple.com
Packit 8cb997
      - name: host02.exmaple.com
Packit 8cb997
        managedby_host: server.exmaple.com
Packit 8cb997
      action: member
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
Packit 8cb997
Example playbook to disable a host:
Packit 8cb997
Packit 8cb997
```yaml
Packit 8cb997
---
Packit 8cb997
- name: Playbook to handle hosts
Packit 8cb997
  hosts: ipaserver
Packit 8cb997
  become: true
Packit 8cb997
Packit 8cb997
  tasks:
Packit 8cb997
  # Ensure host is disabled
Packit 8cb997
  - ipahost:
Packit 8cb997
      ipaadmin_password: MyPassword123
Packit 8cb997
      name: host01.example.com
Packit 8cb997
      update_dns: yes
Packit 8cb997
      state: disabled
Packit 8cb997
```
Packit e64f81
`update_dns` controls if the DNS entries will be updated in this case. For `state` present it is controlling the update of the DNS SSHFP records, but not the the other DNS records.
Packit 8cb997
Packit 8cb997
Packit 8cb997
Example playbook to ensure a host is absent:
Packit 8cb997
Packit 8cb997
```yaml
Packit 8cb997
---
Packit 8cb997
- name: Playbook to handle hosts
Packit 8cb997
  hosts: ipaserver
Packit 8cb997
  become: true
Packit 8cb997
Packit 8cb997
  tasks:
Packit 8cb997
  # Ensure host is absent
Packit 8cb997
  - ipahost:
Packit 8cb997
      ipaadmin_password: password1
Packit 8cb997
      name: host01.example.com
Packit 8cb997
      state: absent
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
Packit 8cb997
Variables
Packit 8cb997
=========
Packit 8cb997
Packit 8cb997
ipahost
Packit 8cb997
-------
Packit 8cb997
Packit 8cb997
Variable | Description | Required
Packit 8cb997
-------- | ----------- | --------
Packit 8cb997
`ipaadmin_principal` | The admin principal is a string and defaults to `admin` | no
Packit 8cb997
`ipaadmin_password` | The admin password is a string and is required if there is no admin ticket available on the node | no
Packit 8cb997
`name` \| `fqdn` | The list of host name strings. `name` with *host variables* or `hosts` containing *host variables* need to be used. | no
Packit 8cb997
**Host variables** | Only used with `name` variable in the first level. | no
Packit 8cb997
`hosts` | The list of host dicts. Each `hosts` dict entry can contain **host variables**.
There is one required option in the `hosts` dict:| no
Packit 8cb997
  | `name` \| `fqdn` - The user name string of the entry. | yes
Packit 8cb997
  | **Host variables** | no
Packit 8cb997
`update_password` |  Set password for a host in present state only on creation or always. It can be one of `always` or `on_create` and defaults to `always`. | no
Packit 8cb997
`action` | Work on host or member level. It can be on of `member` or `host` and defaults to `host`. | no
Packit 8cb997
`state` | The state to ensure. It can be one of `present`, `absent` or `disabled`, default: `present`. | yes
Packit 8cb997
Packit 8cb997
Packit 8cb997
**Host Variables:**
Packit 8cb997
Packit 8cb997
Variable | Description | Required
Packit 8cb997
-------- | ----------- | --------
Packit 8cb997
`description` | The host description. | no
Packit 8cb997
`locality` | Host locality (e.g. "Baltimore, MD"). | no
Packit 8cb997
`location` \| `ns_host_location` | Host location (e.g. "Lab 2"). | no
Packit 8cb997
`platform` \| `ns_hardware_platform` | Host hardware platform (e.g. "Lenovo T61"). | no
Packit 8cb997
`os` \| `ns_os_version` | Host operating system and version (e.g. "Fedora 9"). | no
Packit 8cb997
`password` \| `user_password` \| `userpassword` | Password used in bulk enrollment. | no
Packit 8cb997
`random` \| `random_password` |  Initiate the generation of a random password to be used in bulk enrollment. | no
Packit 8cb997
`certificate` \| `usercertificate` | List of base-64 encoded host certificates | no
Packit 8cb997
`managedby` \| `principalname` \| `krbprincipalname` | List of hosts that can manage this host | no
Packit 8cb997
`principal` \| `principalname` \| `krbprincipalname` | List of principal aliases for this host | no
Packit 8cb997
`allow_create_keytab_user` \| `ipaallowedtoperform_write_keys_user` | Users allowed to create a keytab of this host. | no
Packit 8cb997
`allow_create_keytab_group` \| `ipaallowedtoperform_write_keys_group` | Groups allowed to create a keytab of this host. | no
Packit 8cb997
`allow_create_keytab_host` \| `ipaallowedtoperform_write_keys_host` | Hosts allowed to create a keytab of this host. | no
Packit 8cb997
`allow_create_keytab_hostgroup` \| `ipaallowedtoperform_write_keys_hostgroup` | Host groups allowed to create a keytab of this host. | no
Packit 8cb997
`allow_retrieve_keytab_user` \| `ipaallowedtoperform_read_keys_user` | Users allowed to retieve a keytab of this host. | no
Packit 8cb997
`allow_retrieve_keytab_group` \| `ipaallowedtoperform_read_keys_group` | Groups allowed to retieve a keytab of this host. | no
Packit 8cb997
`allow_retrieve_keytab_host` \| `ipaallowedtoperform_read_keys_host` | Hosts allowed to retieve a keytab of this host. | no
Packit 8cb997
`allow_retrieve_keytab_hostgroup` \| `ipaallowedtoperform_read_keys_hostgroup` | Host groups allowed to retieve a keytab of this host. | no
Packit 8cb997
`mac_address` \| `macaddress` | List of hardware MAC addresses. | no
Packit 8cb997
`sshpubkey` \| `ipasshpubkey` | List of SSH public keys | no
Packit 8cb997
`userclass` \| `class` | Host category (semantics placed on this attribute are for local interpretation) | no
Packit 98a68e
`auth_ind` \| `krbprincipalauthind` | Defines a whitelist for Authentication Indicators. Use 'otp' to allow OTP-based 2FA authentications. Use 'radius' to allow RADIUS-based 2FA authentications. Use empty string to reset auth_ind to the initial value. Other values may be used for custom configurations. choices: ["radius", "otp", "pkinit", "hardened", ""] | no
Packit 8cb997
`requires_pre_auth` \| `ipakrbrequirespreauth` | Pre-authentication is required for the service (bool) | no
Packit 8cb997
`ok_as_delegate` \| `ipakrbokasdelegate` | Client credentials may be delegated to the service (bool) | no
Packit 8cb997
`ok_to_auth_as_delegate` \| `ipakrboktoauthasdelegate` | The service is allowed to authenticate on behalf of a client (bool) | no
Packit 8cb997
`force` | Force host name even if not in DNS. | no
Packit 8cb997
`reverse` | Reverse DNS detection. | no
Packit e64f81
`ip_address` \| `ipaddress` | The host IP address list. It can contain IPv4 and IPv6 addresses. No conflict check for IP addresses is done. | no
Packit e64f81
`update_dns` | For existing hosts: DNS SSHFP records are updated with `state` present and all DNS entries for a host removed with `state` absent. | no
Packit 8cb997
Packit 8cb997
Packit 8cb997
Return Values
Packit 8cb997
=============
Packit 8cb997
Packit 8cb997
ipahost
Packit 8cb997
-------
Packit 8cb997
Packit 8cb997
There are only return values if one or more random passwords have been generated.
Packit 8cb997
Packit 8cb997
Variable | Description | Returned When
Packit 8cb997
-------- | ----------- | -------------
Packit 8cb997
`host` | Host dict with random password. (dict) 
Options: | If random is yes and host did not exist or update_password is yes
Packit 8cb997
  | `randompassword` - The generated random password | If only one host is handled by the module
Packit 8cb997
  | `name` - The host name of the host that got a new random password. (dict) 
Options:
  `randompassword` - The generated random password | If several hosts are handled by the module
Packit 8cb997
Packit 8cb997
Packit 8cb997
Authors
Packit 8cb997
=======
Packit 8cb997
Packit 8cb997
Thomas Woerner