Blame README.md

Packit 8cb997
FreeIPA Ansible collection
Packit 8cb997
==========================
Packit 8cb997
Packit 8cb997
This repository contains [Ansible](https://www.ansible.com/) roles and playbooks to install and uninstall [FreeIPA](https://www.freeipa.org/) `servers`, `replicas` and `clients`. Also modules for group, host, topology and user management.
Packit 8cb997
Packit 8cb997
**Note**: The ansible playbooks and roles require a configured ansible environment where the ansible nodes are reachable and are properly set up to have an IP address and a working package manager.
Packit 8cb997
Packit 8cb997
Features
Packit 8cb997
--------
Packit 8cb997
* Server, replica and client deployment
Packit 8cb997
* Cluster deployments: Server, replicas and clients in one playbook
Packit 8cb997
* One-time-password (OTP) support for client installation
Packit 8cb997
* Repair mode for clients
Packit 8cb997
* Modules for group management
Packit 8cb997
* Modules for hbacrule management
Packit 8cb997
* Modules for hbacsvc management
Packit 8cb997
* Modules for hbacsvcgroup management
Packit 8cb997
* Modules for host management
Packit 8cb997
* Modules for hostgroup management
Packit 8cb997
* Modules for pwpolicy management
Packit 8cb997
* Modules for sudocmd management
Packit 8cb997
* Modules for sudocmdgroup management
Packit 8cb997
* Modules for sudorule management
Packit 8cb997
* Modules for topology management
Packit 8cb997
* Modules for user management
Packit 8cb997
Packit 8cb997
Supported FreeIPA Versions
Packit 8cb997
--------------------------
Packit 8cb997
Packit 8cb997
FreeIPA versions 4.6 and up are supported by all roles. 
Packit 8cb997
Packit 8cb997
The client role supports versions 4.4 and up, the server role is working with versions 4.5 and up, the replica role is currently only working with versions 4.6 and up.
Packit 8cb997
Packit 8cb997
Supported Distributions
Packit 8cb997
-----------------------
Packit 8cb997
Packit 8cb997
* RHEL/CentOS 7.4+
Packit 8cb997
* Fedora 26+
Packit 8cb997
* Ubuntu
Packit 8cb997
* Debian 10+ (ipaclient only, no server or replica!)
Packit 8cb997
Packit 8cb997
Requirements
Packit 8cb997
------------
Packit 8cb997
Packit 8cb997
**Controller**
Packit 8cb997
* Ansible version: 2.8+ (ansible-freeipa is an Ansible Collection)
Packit 8cb997
* /usr/bin/kinit is required on the controller if a one time password (OTP) is used
Packit 8cb997
* python3-gssapi is required on the controller if a one time password (OTP) is used with keytab to install the client.
Packit 8cb997
Packit 8cb997
**Node**
Packit 8cb997
* Supported FreeIPA version (see above)
Packit 8cb997
* Supported distribution (needed for package installation only, see above)
Packit 8cb997
Packit 8cb997
Limitations
Packit 8cb997
-----------
Packit 8cb997
Packit 8cb997
**External signed CA**
Packit 8cb997
Packit 8cb997
External signed CA is now supported. But the currently needed two step process is an issue for the processing in a simple playbook.
Packit 8cb997
Packit 8cb997
Work is planned to have a new method to handle CSR for external signed CAs in a separate step before starting the server installation.
Packit 8cb997
Packit 8cb997
Packit 8cb997
Usage
Packit 8cb997
=====
Packit 8cb997
Packit 8cb997
How to use ansible-freeipa
Packit 8cb997
--------------------------
Packit 8cb997
Packit 8cb997
**GIT repo**
Packit 8cb997
Packit 8cb997
The simplest method for now is to clone this repository on the controller from github directly and to start the deployment from the ansible-freeipa directory:
Packit 8cb997
Packit 8cb997
```bash
Packit 8cb997
git clone https://github.com/freeipa/ansible-freeipa.git
Packit 8cb997
cd ansible-freeipa
Packit 8cb997
```
Packit 8cb997
You can use the roles directly within the top directory of the git repo, but to be able to use the management modules in the plugins subdirectory, you have to either adapt `ansible.cfg` or create links for the roles, modules or directories.
Packit 8cb997
Packit 8cb997
You can either adapt ansible.cfg:
Packit 8cb997
Packit 8cb997
```
Packit 8cb997
roles_path   = /my/dir/ansible-freeipa/roles
Packit 8cb997
library      = /my/dir/ansible-freeipa/plugins/modules
Packit 8cb997
module_utils = /my/dir/ansible-freeipa/plugins/module_utils
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
Or you can link the directories:
Packit 8cb997
Packit 8cb997
```
Packit 8cb997
ansible-freeipa/roles to ~/.ansible/
Packit 8cb997
ansible-freeipa/plugins/modules to ~/.ansible/plugins/
Packit 8cb997
ansible-freeipa/plugins/module_utils to ~/.ansible/plugins/
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
**RPM package**
Packit 8cb997
Packit 8cb997
There are RPM packages available for Fedora 29+. These are installing the roles and modules into the global Ansible directories for `roles`, `plugins/modules` and `plugins/module_utils` in the `/usr/share/ansible` directory. Therefore is it possible to use the roles and modules without adapting the names like it is done in the example playbooks.
Packit 8cb997
Packit 8cb997
**Ansible galaxy**
Packit 8cb997
Packit 8cb997
This command will get the whole collection from galaxy:
Packit 8cb997
Packit 8cb997
```bash
Packit 8cb997
ansible-galaxy collection install freeipa.ansible_freeipa
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
Installing collections using the ansible-galaxy command is only supported with ansible 2.9+.
Packit 8cb997
Packit 8cb997
The mazer tool can be used for to install the collection for ansible 2.8:
Packit 8cb997
Packit 8cb997
```bash
Packit 8cb997
mazer install freeipa.ansible_freeipa
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
Ansible galaxy does not support the use of dash ('-') in a name and is automatically replacing this with an underscore ('\_'). Therefore the name is `ansible_freeipa`. The ansible_freeipa collection will be placed in the directory `~/.ansible/collections/ansible_collections/freeipa/ansible_freeipa` where it will be automatically be found for this user.
Packit 8cb997
Packit 8cb997
The needed adaptions of collection prefixes for `modules` and `module_utils` will be done with ansible-freeipa release `0.1.6` for galaxy.
Packit 8cb997
Packit 8cb997
Packit 8cb997
Ansible inventory file
Packit 8cb997
----------------------
Packit 8cb997
Packit 8cb997
The most important parts of the inventory file is the definition of the nodes, settings and the management modules. Please remember to use [Ansible vault](https://docs.ansible.com/ansible/latest/user_guide/vault.html) for passwords. The examples here are not using vault for better readability.
Packit 8cb997
Packit 8cb997
**Master server**
Packit 8cb997
Packit 8cb997
The master server is defined within the ```[ipaserver]``` group:
Packit 8cb997
```yaml
Packit 8cb997
[ipaserver]
Packit 8cb997
ipaserver.test.local
Packit 8cb997
```
Packit 8cb997
There are variables that need to be set like ```domain```, ```realm```, ```admin password``` and ```dm password```. These can be set in the ```[ipaserver:vars]``` section:
Packit 8cb997
```yaml
Packit 8cb997
[ipaserver:vars]
Packit 8cb997
ipaadmin_password=ADMPassword1
Packit 8cb997
ipadm_password=DMPassword1
Packit 8cb997
ipaserver_domain=test.local
Packit 8cb997
ipaserver_realm=TEST.LOCAL
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
The admin principle is ```admin``` by default. Please set ```ipaadmin_principal``` if you need to change it.
Packit 8cb997
Packit 8cb997
You can also add more setting here, like for example to enable the DNS server or to set auto-forwarders:
Packit 8cb997
```yaml
Packit 8cb997
[ipaserver:vars]
Packit 8cb997
ipaserver_setup_dns=yes
Packit 8cb997
ipaserver_auto_forwarders=yes
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
But also to skip package installation or firewalld configuration:
Packit 8cb997
```yaml
Packit 8cb997
[ipaserver:vars]
Packit 8cb997
ipaserver_install_packages=no
Packit 8cb997
ipaserver_setup_firewalld=no
Packit 8cb997
```
Packit 8cb997
The installation of packages and also the configuration of the firewall are by default enabled.
Packit 8cb997
Note that it is not enough to mask systemd firewalld service to skip the firewalld configuration. You need to set the variable to `no`.
Packit 8cb997
Packit 8cb997
For more server settings, please have a look at the [server role documentation](roles/ipaserver/README.md).
Packit 8cb997
Packit 8cb997
**Replica**
Packit 8cb997
Packit 8cb997
The replicas are defined within the ```[ipareplicas]``` group:
Packit 8cb997
```yaml
Packit 8cb997
[ipareplicas]
Packit 8cb997
ipareplica1.test.local
Packit 8cb997
ipareplica2.test.local
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
If the master server is already deployed and there are DNS txt records to be able to auto-detect the server, then it is not needed to set ```domain``` or ```realm``` for the replica deployment. But it might be needed to set the master server of a replica because of the topology. If this is needed, it can be set either in the ```[ipareplicas:vars]``` section if it will apply to all the replicas in the ```[ipareplicas]``` group or it is possible to set this also per replica in the ```[ipareplicas]``` group:
Packit 8cb997
```yaml
Packit 8cb997
[ipareplicas]
Packit 8cb997
ipareplica1.test.local
Packit 8cb997
ipareplica2.test.local ipareplica_servers=ipareplica1.test.local
Packit 8cb997
```
Packit 8cb997
This will create a chain from ```ipaserver.test.local <- ipareplica1.test.local <- ipareplica2.test.local```.
Packit 8cb997
Packit 8cb997
If you need to set more than one server for a replica (for fallbacks etc.), simply use a comma separated list for ```ipareplica_servers```:
Packit 8cb997
```yaml
Packit 8cb997
[ipareplicas_tier1]
Packit 8cb997
ipareplica1.test.local
Packit 8cb997
Packit 8cb997
[ipareplicas_tier2]
Packit 8cb997
ipareplica2.test.local ipareplica_servers=ipareplica1.test.local,ipaserver.test.local
Packit 8cb997
```
Packit 8cb997
The first entry in ```ipareplica_servers``` will be used as the master.
Packit 8cb997
Packit 8cb997
In this case you need to have separate tasks in the playbook to first deploy replicas from tier1 and then replicas from tier2:
Packit 8cb997
```yaml
Packit 8cb997
---
Packit 8cb997
- name: Playbook to configure IPA replicas (tier1)
Packit 8cb997
  hosts: ipareplicas_tier1
Packit 8cb997
  become: true
Packit 8cb997
Packit 8cb997
  roles:
Packit 8cb997
  - role: ipareplica
Packit 8cb997
    state: present
Packit 8cb997
Packit 8cb997
- name: Playbook to configure IPA replicas (tier2)
Packit 8cb997
  hosts: ipareplicas_tier2
Packit 8cb997
  become: true
Packit 8cb997
Packit 8cb997
  roles:
Packit 8cb997
  - role: ipareplica
Packit 8cb997
    state: present
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
You can add settings for replica deployment:
Packit 8cb997
```yaml
Packit 8cb997
[ipareplicas:vars]
Packit 8cb997
ipaadmin_password=ADMPassword1
Packit 8cb997
ipadm_password=DMPassword1
Packit 8cb997
ipaserver_domain=test.local
Packit 8cb997
ipaserver_realm=TEST.LOCAL
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
You can also add more setting here, like for example to setup DNS or to enable auto-forwarders:
Packit 8cb997
```yaml
Packit 8cb997
[ipareplica:vars]
Packit 8cb997
ipaserver_setup_dns=yes
Packit 8cb997
ipaserver_auto_forwarders=yes
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
If you need to skip package installation or firewalld configuration:
Packit 8cb997
Packit 8cb997
```yaml
Packit 8cb997
[ipareplicas:vars]
Packit 8cb997
ipareplica_install_packages=no
Packit 8cb997
ipareplica_setup_firewalld=no
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
The installation of packages and also the configuration of the firewall are by default enabled.
Packit 8cb997
Note that it is not enough to mask systemd firewalld service to skip the firewalld configuration. You need to set the variable to `no`.
Packit 8cb997
Packit 8cb997
For more replica settings, please have a look at the [replica role documentation](roles/ipareplica/README.md).
Packit 8cb997
Packit 8cb997
Packit 8cb997
**Client**
Packit 8cb997
Packit 8cb997
Clients are defined within the [ipaclients] group:
Packit 8cb997
```yaml
Packit 8cb997
[ipaclients]
Packit 8cb997
ipaclient1.test.local
Packit 8cb997
ipaclient2.test.local
Packit 8cb997
ipaclient3.test.local
Packit 8cb997
ipaclient4.test.local
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
For simple setups or in defined client environments it might not be needed to set domain or realm for the replica deployment. But it might be needed to set the master server of a client because of the topology. If this is needed, it can be set either in the [ipaclients:vars} section if it will apply to all the clients in the [ipaclients] group or it is possible to set this also per client in the [ipaclients] group:
Packit 8cb997
```yaml
Packit 8cb997
[ipaclients]
Packit 8cb997
ipaclient1.test.local ipaclient_servers=ipareplica1.test.local
Packit 8cb997
ipaclient2.test.local ipaclient_servers=ipareplica1.test.local
Packit 8cb997
ipaclient3.test.local ipaclient_servers=ipareplica2.test.local
Packit 8cb997
ipaclient4.test.local ipaclient_servers=ipareplica2.test.local
Packit 8cb997
```
Packit 8cb997
If you need to set more than one server for a client (for fallbacks etc.), simply use a comma separated list for ```ipaclient_servers```.
Packit 8cb997
Packit 8cb997
You can add settings for client deployment:
Packit 8cb997
```yaml
Packit 8cb997
[ipaclients:vars]
Packit 8cb997
ipaadmin_password=ADMPassword1
Packit 8cb997
ipaserver_domain=test.local
Packit 8cb997
ipaserver_realm=TEST.LOCAL
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
For enhanced security it is possible to use a auto-generated one-time-password (OTP). This will be generated on the controller using the (first) server. It is needed to have the Python gssapi bindings installed on the controller for this.
Packit 8cb997
To enable the generation of the one-time-password:
Packit 8cb997
```yaml
Packit 8cb997
[ipaclients:vars]
Packit 8cb997
ipaclient_use_otp=yes
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
For more client settings, please have a look at the [client role documentation](roles/ipaclient/README.md).
Packit 8cb997
Packit 8cb997
**Cluster**
Packit 8cb997
Packit 8cb997
If you want to deploy more than a master server at once, then it will be good to define a new group like ```[ipacluster]``` that contains all the other groups ```[ipaserver]```, ```[ipareplicas]``` and ```[ipaclients]```. This way it is not needed to set ```domain```, ```realm```, ```admin password``` or ```dm password``` for the single groups:
Packit 8cb997
```yaml
Packit 8cb997
[ipacluster:children]
Packit 8cb997
ipaserver
Packit 8cb997
ipareplicas
Packit 8cb997
ipaclients
Packit 8cb997
Packit 8cb997
[ipacluster:vars]
Packit 8cb997
ipaadmin_password=ADMPassword1
Packit 8cb997
ipadm_password=DMPassword1
Packit 8cb997
ipaserver_domain=test.local
Packit 8cb997
ipaserver_realm=TEST.LOCAL
Packit 8cb997
```
Packit 8cb997
All these settings will be available in the ```[ipaserver]```, ```[ipareplicas]``` and ```[ipaclient]``` groups.
Packit 8cb997
Packit 8cb997
**Topology**
Packit 8cb997
Packit 8cb997
With this playbook it is possible to add a list of topology segments using the `ipatopologysegment` module.
Packit 8cb997
Packit 8cb997
```yaml
Packit 8cb997
---
Packit 8cb997
- name: Add topology segments
Packit 8cb997
  hosts: ipaserver
Packit 8cb997
  become: true
Packit 8cb997
  gather_facts: false
Packit 8cb997
Packit 8cb997
  vars:
Packit 8cb997
    ipaadmin_password: password1
Packit 8cb997
    ipatopology_segments:
Packit 8cb997
    - {suffix: domain, left: replica1.test.local, right: replica2.test.local}
Packit 8cb997
    - {suffix: domain, left: replica2.test.local, right: replica3.test.local}
Packit 8cb997
    - {suffix: domain, left: replica3.test.local, right: replica4.test.local}
Packit 8cb997
    - {suffix: domain+ca, left: replica4.test.local, right: replica1.test.local}
Packit 8cb997
Packit 8cb997
  tasks:
Packit 8cb997
  - name: Add topology segment
Packit 8cb997
    ipatopologysegment:
Packit 8cb997
      password: "{{ ipaadmin_password }}"
Packit 8cb997
      suffix: "{{ item.suffix }}"
Packit 8cb997
      name: "{{ item.name | default(omit) }}"
Packit 8cb997
      left: "{{ item.left }}"
Packit 8cb997
      right: "{{ item.right }}"
Packit 8cb997
      #state: present
Packit 8cb997
      #state: absent
Packit 8cb997
      #state: checked
Packit 8cb997
      state: reinitialized
Packit 8cb997
    loop: "{{ ipatopology_segments | default([]) }}"
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
Packit 8cb997
Packit 8cb997
Playbooks
Packit 8cb997
=========
Packit 8cb997
Packit 8cb997
The playbooks needed to deploy or undeploy server, replicas and clients are part of the repository and placed in the playbooks folder. There are also playbooks to deploy and undeploy clusters. With them it is only needed to add an inventory file:
Packit 8cb997
```
Packit 8cb997
playbooks\
Packit 8cb997
        install-client.yml
Packit 8cb997
        install-cluster.yml
Packit 8cb997
        install-replica.yml
Packit 8cb997
        install-server.yml
Packit 8cb997
        uninstall-client.yml
Packit 8cb997
        uninstall-cluster.yml
Packit 8cb997
        uninstall-replica.yml
Packit 8cb997
        uninstall-server.yml
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
How to deploy a master server
Packit 8cb997
-----------------------------
Packit 8cb997
Packit 8cb997
```bash
Packit 8cb997
ansible-playbook -v -i inventory/hosts install-server.yml
Packit 8cb997
```
Packit 8cb997
This will deploy the master server defined in the inventory file.
Packit 8cb997
Packit 8cb997
If Ansible vault is used for passwords, then it is needed to adapt the playbooks in this way:
Packit 8cb997
```yaml
Packit 8cb997
---
Packit 8cb997
- name: Playbook to configure IPA servers
Packit 8cb997
  hosts: ipaserver
Packit 8cb997
  become: true
Packit 8cb997
  vars_files:
Packit 8cb997
  - playbook_sensitive_data.yml
Packit 8cb997
Packit 8cb997
  roles:
Packit 8cb997
  - role: ipaserver
Packit 8cb997
    state: present
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
It is also needed to provide the vault password file on the ansible-playbook command line:
Packit 8cb997
```bash
Packit 8cb997
ansible-playbook -v -i inventory/hosts --vault-password-file .vaul_pass.txt install-server.yml
Packit 8cb997
```
Packit 8cb997
Packit 8cb997
How to deploy a replica
Packit 8cb997
-----------------------
Packit 8cb997
Packit 8cb997
```bash
Packit 8cb997
ansible-playbook -v -i inventory/hosts install-replica.yml
Packit 8cb997
```
Packit 8cb997
This will deploy the replicas defined in the inventory file.
Packit 8cb997
Packit 8cb997
How to setup a client
Packit 8cb997
---------------------
Packit 8cb997
Packit 8cb997
```bash
Packit 8cb997
ansible-playbook -v -i inventory/hosts install-client.yml
Packit 8cb997
```
Packit 8cb997
This will deploy the clients defined in the inventory file.
Packit 8cb997
Packit 8cb997
How to deploy a cluster
Packit 8cb997
-----------------------
Packit 8cb997
Packit 8cb997
```bash
Packit 8cb997
ansible-playbook -v -i inventory/hosts install-cluster.yml
Packit 8cb997
```
Packit 8cb997
This will deploy the server, replicas and clients defined in the inventory file.
Packit 8cb997
Packit 8cb997
Packit 8cb997
Roles
Packit 8cb997
=====
Packit 8cb997
Packit 8cb997
* [Server](roles/ipaserver/README.md)
Packit 8cb997
* [Replica](roles/ipareplica/README.md)
Packit 8cb997
* [Client](roles/ipaclient/README.md)
Packit 8cb997
Packit 8cb997
Modules in plugin/modules
Packit 8cb997
=========================
Packit 8cb997
Packit 8cb997
* [ipagroup](README-group.md)
Packit 8cb997
* [ipahbacrule](README-hbacrule.md)
Packit 8cb997
* [ipahbacsvc](README-hbacsvc.md)
Packit 8cb997
* [ipahbacsvcgroup](README-hbacsvc.md)
Packit 8cb997
* [ipahost](README-host.md)
Packit 8cb997
* [ipahostgroup](README-hostgroup.md)
Packit 8cb997
* [ipapwpolicy](README-pwpolicy.md)
Packit 8cb997
* [ipasudocmd](README-sudocmd.md)
Packit 8cb997
* [ipasudocmdgroup](README-sudocmdgroup.md)
Packit 8cb997
* [ipasudorule](README-sudorule.md)
Packit 8cb997
* [ipatopologysegment](README-topology.md)
Packit 8cb997
* [ipatopologysuffix](README-topology.md)
Packit 8cb997
* [ipauser](README-user.md)