NODES Playbook

    Once pigsty is installed on the meta node with infra.yml, You can add more nodes to Pigsty with or remove them from Pigsty with nodes-remove.yml.


    The nodes.yml playbook will register nodes to Pigsty.

    This playbook adjusts the target nodes to the state described in the , installs the Consul service, and incorporates it into the Pigsty monitoring system. Nodes can be used for database deployment once provisioning is complete.

    The behavior of this playbook is determined by the Config: NODES. The complete execution of this playbook may take 1 to 3 minutes when using the local yum repo, depending on the machine spec.

    This playbook will run the following tasks:

    • Generate node
    • Provisioning Node
      • Configure the node’s hostname
      • Configure static DNS records
      • Configure dynamic DNS resolver
      • Install specified RPM packages
      • Configure features such as NUMA/SWAP/firewall
      • Configure node tuned tuning templates
      • Configure shortcuts and environment variables for the node
      • Create node admin user and configure its SSH access
      • Configure timezone
      • Configure NTP service
    • Initialize the DCS service on the node: Consul
      • Erase existing Consul if it exists (with protection disabled)
      • Initialize the Consul Agent or Server service for the current node
    • Initialize the node monitoring component and incorporate Pigsty
      • Register Node Exporter to Prometheus on meta nodes.

    Pigsty provides a SafeGuard to avoid purging running consul instances with fat fingers. There are two parameters.

    • : Disabled by default, if enabled, running consul will not be purged by any circumstance.
    • dcs_clean: disabled by default, will purge running consul during node init.

    When running consul exists, nodes.yml will act as:

    When running consul exists, will act as:

    You can selectively execute a subset of this playbook through tags.

    For example, if you want to re-deploy node monitor components only:

    1. ./nodes.yml --tags=node-monitor

    Common tasks are listed below:

    Admin user provisioning is a chicken-and-egg problem. To execute playbooks, you need to have an admin user. To create a dedicated admin user, you need to run this playbook.

    It may require a password to execute ssh & sudo. You can pass them via extra params and --ask-become-pass|-K, entering SSH and sudo password when prompted. You can create a dedicated admin user (with no pass sudo & ssh) with another admin user (with password sudo & ssh).

    The following parameters are used to describe the dedicated admin user.

    1. ./nodes.yml -t node_admin -l <target_hosts> --ask-pass --ask-become-pass

    The default admin user is dba (uid=88). Please do not use postgres or {{ dbsu }} as the admin user. Please try to avoid using root as the admin user directly.

    The default user vagrant in the local sandbox has been provisioned with nopass ssh & sudo. You can use vagrant to ssh to all other nodes from the sandbox meta node.

    Refer to: for more details.


    nodes-remove

    The playbook is used to remove nodes from Pigsty.

    The playbook needs to be executed on meta nodes, and targeting nodes need to be removed.

    1. ./nodes.yml # Remove all nodes (dangerous!)
    2. ./nodes.yml -l nodes-test # Remove nodes under group nodes-test

    Playbook - 图2