11.9. Exporting a cluster configuration to create a RHEL system role playbook


You can use the ha_cluster RHEL system role to export the Corosync configuration of a cluster into ha_cluster variables that can be fed back to the role to recreate the same cluster.

If you did not use ha_cluster to create your cluster, or if you do not have access to the original playbook for the cluster, you can use this feature to build a new playbook for creating the cluster.

When you export a cluster’s configuration by using the ha_cluster RHEL system role, not all of the variables are exported. You must manually modify the configuration to account for these variables.

The following variables are present in the export:

  • ha_cluster_cluster_present
  • ha_cluster_start_on_boot
  • ha_cluster_cluster_name
  • ha_cluster_transport
  • ha_cluster_totem
  • ha_cluster_quorum
  • ha_cluster_node_options - Only the node_name, corosync_addresses and pcs_address options are present.
  • ha_cluster_enable_repos
  • ha_cluster_enable_repos_resilient_storage
  • ha_cluster_manage_firewall
  • ha_cluster_manage_selinux
  • ha_cluster_install_cloud_agents
  • ha_cluster_pcs_permission_list
  • ha_cluster_resource_primitives
  • ha_cluster_resource_groups
  • ha_cluster_resource_clones
  • ha_cluster_resource_bundles

The following variables are not present in the export:

  • ha_cluster_hacluster_password - This is a mandatory variable for the role but it cannot be extracted from existing clusters.
  • ha_cluster_corosync_key_src, ha_cluster_pacemaker_key_src and ha_cluster_fence_virt_key_src - These variables should contain paths to files with Corosync and Pacemaker keys. Since the keys themselves are not exported, these variables are not present in the export either. These keys should be unique for each cluster.
  • ha_cluster_regenerate_keys - You should decide whether to use existing keys or to generate new ones.
  • ha_cluster_hacluster_qdevice_password - Specifies the password for the ha_cluster user on a quorum device. This is a required setting when using a quorum device to avoid manual intervention. It cannot be extracted from existing clusters.
  • ha_cluster_fence_agent_packages - A list of fence agent packages to install.
  • ha_cluster_extra_packages - Specifies any extra packages to be installed on the cluster nodes.
  • ha_cluster_use_latest_packages - When set to true, the system role will use the latest available packages for the cluster.
  • ha_cluster_pcsd_public_key_src, ha_cluster_pcsd_private_key_src - These variables should contain paths to TLS certificate and private key for pcsd. Since the certificate and key themselves are not exported, these variables are not present in the export either.
  • ha_cluster_pcsd_certificates - When this variable is set, the certificate RHEL system role is used internally to create the private key and certificate for pcsd. It cannot be extracted from existing clusters.

To export the current cluster configuration, run the ha_cluster RHEL system role and set ha_cluster_export_configuration: true. This triggers the export once the role finishes configuring a cluster or a qnetd host and stores it in the ha_cluster_facts variable.

By default, ha_cluster_cluster_present is set to true and ha_cluster_qnetd.present is set to false. These settings will reconfigure your cluster on the specified hosts, remove qnetd configuration from the specified hosts, and then export the configuration. To trigger the export without modifying an existing configuration, run the role with the following settings:

- hosts: node1
  vars:
    ha_cluster_cluster_present: null
    ha_cluster_qnetd: null
    ha_cluster_export_configuration: true

  roles:
    - linux-system-roles.ha_cluster

The following procedure:

  • Exports the cluster configuration from cluster node node1 into the ha_cluster_facts variable.
  • Sets the ha_cluster_cluster_present and ha_cluster_qnetd variables to null to ensure that running this playbook does not modify the existing cluster configuration.
  • Uses the Ansible debug module to display the content of ha_cluster_facts.
  • Saves the contents of ha_cluster_facts to a file on the control node in a YAML format for you to write a playbook around it.

Prerequisites

Procedure

  1. Create a playbook file, for example, ~/playbook.yml, with the following content:

    ---
    - name: Export high availability cluster configuration
      hosts: node1
      Tasks:
        - name: Export configuration that does not modify existing cluster
          ansible.builtin.include_role:
            name: redhat.rhel_system_roles.ha_cluster
          vars:
            ha_cluster_cluster_present: null
            ha_cluster_qnetd: null
            ha_cluster_export_configuration: true
        - name: Print ha_cluster_info_result variable
          ansible.builtin.debug:
            var: ha_cluster_facts
        - name: Save current cluster configuration to a file
          delegate_to: localhost
          ansible.builtin.copy:
            content: "{{ ha_cluster_facts | to_nice_yaml(sort_keys=false) }}"
            dest: /path/to/file
            mode: "0640"

    The settings specified in the example playbook include the following:

    hosts: node1
    A node containing the cluster information to export.
    ha_cluster_cluster_present: null
    Setting to indicate that the cluster configuration will not be changed on the specified host.
    ha_cluster_qnetd: null
    Setting to indicate that the qnetd host configuration will not be changed on the specified host.
    ha_cluster_export_configuration: true
    A variable that determines whether to export the current cluster configuration and store it in the ha_cluster_facts variable, which is generated by the ha_cluster_info module.
    ha_cluster_facts
    A variable that contains the exported cluster configuration.
    delegate_to: localhost
    Specifies the control node as the location for the exported configuration file.
    content: "{{ ha_cluster_facts | to_nice_yaml(sort_keys=false) }"}, dest: /path/to/file, mode: "0640"

    Copies the configuration file in a YAML format to /path/to/file, setting the file permissions to 0640.

    For details about all variables used in the playbook, see the /usr/share/ansible/roles/rhel-system-roles.ha_cluster/README.md file on the control node.

  2. Validate the playbook syntax:

    $ ansible-playbook --syntax-check ~/playbook.yml

    Note that this command only validates the syntax and does not protect against a wrong but valid configuration.

  3. Run the playbook:

    $ ansible-playbook ~/playbook.yml
  4. After you have exported the current cluster configuration, you can write a playbook for your system using the variables you exported to /path/to/file on the control node.

    You must add the ha_cluster_hacluster_password variable, as it is a required variable but is not present in the export. Optionally, add the ha_cluster_corosync_key_src, ha_cluster_pacemaker_key_src, ha_cluster_fence_virt_key_src, and ha_cluster_regenerate_keys variables if your system requires them. These variables are never exported.

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部