Skip to content

Roles Variables

Kostiantyn Nemchenko edited this page Dec 11, 2019 · 1 revision
patroni_postgresql_version
  • Description: Version of PostgreSQL to install
  • Default: 11
patroni_postgresql_exists
  • Description: Whether or not to install PostgreSQL and related packages
  • Default: false
patroni_config_dir
  • Description: Path to directory with Patroni configuration file
  • Default: /etc/patroni
patroni_system_user
  • Description: OS user that will own PostgreSQL data files and Patroni process
  • Default: postgres
patroni_system_group
  • Description: OS group that will own PostgreSQL data files and Patroni process
  • Default: postgres
patroni_exec_start_pre
  • Description: Command to execute before the main Patroni process will be started
  • Default: /bin/mkdir -m 2750 -p /var/run/postgresql/{{ patroni_postgresql_version }}-main.pg_stat_tmp
patroni_pip_packages
  • Description: List of PIP packages to install
  • Default:
- {
    name: "setuptools",
    state: "latest",
    umask: "0022",
    executable: "pip3" 
  }
- {
    name: "patroni[{{ patroni_dcs }}]",
    state: "present",
    umask: "0022",
    executable: "pip3"
  }
patroni_replication_username
  • Description: Name of the user that will be created during initialization. Replicas will use this user to access master via streaming replication
  • Default: replicator
patroni_replication_password
  • Description: Password of the user that will be used by replicas to access primary node via streaming replication
  • Default: repuserpasswd
patroni_superuser_username
  • Description: Name of the user that will be created during initialization and later used by Patroni to connect to the local postgres instance. This user also will be used by Patroni to execute pg_rewind on PostgreSQL 10 and earlier versions.
  • Default: postgres
patroni_superuser_password
  • Description: Password of the super user that will be used by Patroni to connect to PostgreSQL instance
  • Default: supersecretpostgrespasswd
patroni_scope
  • Description: Patroni cluster name
  • Default: main
patroni_namespace
  • Description: Path within the configuration store where Patroni will keep information about the cluster
  • Default: /service/
patroni_name
  • Description: Name of the node where the current instance of Patroni is running. Must be unique for the cluster
  • Default: {{ inventory_hostname }}
patroni_log_destination
  • Description: By default Patroni writes its logs into the stderr. If value for this variable is not equal to "stderr" then all logs will be written to the file {{ patroni_log_dir }}/patroni.log
  • Default: stderr
patroni_log_level
  • Description: General logging level
  • Default: INFO
patroni_log_format
  • Description: Log formatting string
  • Default: %(asctime)s %(levelname)s: %(message)s
patroni_log_dateformat
  • Description: Datetime formatting string
  • Default: ""
patroni_log_max_queue_size
  • Description: Patroni is using two-step logging. Log records are written into the in-memory queue and there is a separate thread which pulls them from the queue and writes to stderr or file. The maximum size of the internal queue is limited by amount of records specified by this parameter. Default value allows to keep logs for the past 80 minutes
  • Default: 1000
patroni_log_dir
  • Description: Directory to write application logs to
  • Default: /var/log/patroni
patroni_log_file_num
  • Description: Number of application logs to retain
  • Default: 4
patroni_log_file_size
  • Description: Size of the {{ patroni_log_dir }}/patroni.log file (in bytes) that triggers a log rolling
  • Default: 25000000
patroni_log_loggers
  • Description: List of python modules along with their logging level
  • Default:
- { module: "patroni.postmaster", level: "WARNING" }
- { module: "urllib3",            level: "DEBUG"   }
patroni_restapi_listen
  • Description: IP address and port that Patroni will listen to, to provide health-check information
  • Default: 0.0.0.0:8008
patroni_restapi_connect_address
  • Description: IP address and port to access the REST API
  • Default: {{ ansible_host }}:8008
patroni_restapi_certfile
  • Description: Specifies the file with the certificate in the PEM format. If the {{ patroni_restapi_certfile }} is not specified or is left empty, the API server will work without SSL
  • Default: ""
patroni_restapi_keyfile
  • Description: Specifies the file with the secret key in the PEM format
  • Default: ""
patroni_restapi_username
  • Description: Basic-auth username to protect unsafe REST API endpoints
  • Default: ""
patroni_restapi_password
  • Description: Basic-auth password to protect unsafe REST API endpoints
  • Default: ""
patroni_dcs
  • Description: Distributed configuration store type (etcd, consul, zookeeper or exhibitor)
  • Default: etcd
patroni_dcs_exists
  • Description: Whether or not to use a recommended Ansible role to setup a DCS. By default we expect you already have a preconfigured DCS cluster. Read more here
  • Default: true
patroni_etcd_host
  • Description: host:port for the etcd endpoint
  • Default: ""
patroni_etcd_hosts
  • Description: List of etcd endpoint in format host1:port1,host2:port2,etc… Could be a comma separated string or an actual yaml list
  • Default: 127.0.0.1:2379
patroni_etcd_use_proxies
  • Description: If enabled Patroni will consider hosts as a list of proxies and will not perform a topology discovery of etcd cluster
  • Default: false
patroni_etcd_url
  • Description: URL for the etcd
  • Default: ""
patroni_etcd_proxy
  • Description: Proxy URL for the etcd. If you are connecting to the etcd using proxy, use this parameter instead of {{ patroni_etcd_url }}
  • Default: ""
patroni_etcd_srv
  • Description: Domain to search the SRV record(s) for cluster autodiscovery
  • Default: ""
patroni_etcd_protocol
  • Description: Protocol used to establish communication between Patroni and Etcd. If the url or proxy is specified - will take protocol from them.
  • Default: http
patroni_etcd_username
  • Description: User name for Etcd authentication
  • Default: ""
patroni_etcd_password
  • Description: User password for Etcd authentication
  • Default: ""
patroni_etcd_cacert
  • Description: Path to the CA certificate. If present it will enable validation
  • Default: ""
patroni_etcd_cert
  • Description: Path to the file with the client certificate
  • Default: ""
patroni_etcd_key
  • Description: Path to the file with the client key. Can be empty if the key is part of {{ patroni_etcd_cert }}
  • Default: ""
patroni_consul_host
  • Description: host:port for the Consul endpoint, in format: http(s)://host:port
  • Default: 127.0.0.1:{{ patroni_consul_port \|default(8500) }}
patroni_consul_port
  • Description: Consul port
  • Default: 8500
patroni_consul_url
  • Description: URL for the Consul endpoint
  • Default: ""
patroni_consul_scheme
  • Description: Protocol used to establish communication between Patroni and Consul
  • Default: http
patroni_consul_token
  • Description: Consul ACL token
  • Default: ""
patroni_consul_verify
  • Description: Whether to verify the SSL certificate for HTTPS requests
  • Default: ""
patroni_consul_cacert
  • Description: Path to the CA certificate. If present it will enable validation
  • Default: ""
patroni_consul_cert
  • Description: Path to the file with the client certificate
  • Default: ""
patroni_consul_key
  • Description: Path to the file with the client key. Can be empty if the key is part of {{ patroni_consul_cert }}
  • Default: ""
patroni_consul_dc
  • Description: Datacenter to communicate with. By default the datacenter of the host is used
  • Default: ""
patroni_consul_checks
  • Description: List of Consul health checks used for the session. If not specified Consul will use “serfHealth” in additional to the TTL based check created by Patroni. Additional checks, in particular the “serfHealth”, may cause the leader lock to expire faster than in ttl seconds when the leader instance becomes unavailable
  • Default: ""
patroni_consul_register_service
  • Description: Whether or not to register a service with the name defined by the scope parameter and the tag master, replica or standby-leader depending on the node’s role
  • Default: false
patroni_consul_service_check_interval
  • Description: How often to perform health check against registered url
  • Default: 5s
patroni_consul_consistency
  • Description: Defines consul consistency mode. Possible values are default, consistent or stale
  • Default: default
patroni_zookeeper_hosts
  • Description: List of ZooKeeper cluster members in format: ['host1:port1', 'host2:port2', 'etc…']
  • Default: 127.0.0.1:2181
patroni_exhibitor_hosts
  • Description: Initial list of Exhibitor (ZooKeeper) nodes in format: 'host1,host2,etc…'. This list updates automatically whenever the Exhibitor (ZooKeeper) cluster topology changes
  • Default: ""
patroni_exhibitor_port
  • Description: Exhibitor port
  • Default: ""
patroni_exhibitor_poll_interval
  • Description: How often the list of ZooKeeper and Exhibitor nodes should be updated from Exhibitor
  • Default: 300
patroni_bootstrap_dcs_ttl
  • Description: TTL to acquire the leader lock (in seconds). Think of it as the length of time before initiation of the automatic failover process
  • Default: 30
patroni_bootstrap_dcs_loop_wait
  • Description: Number of seconds the HA loop will sleep
  • Default: 10
patroni_bootstrap_dcs_retry_timeout
  • Description: Timeout for DCS and PostgreSQL operation retries (in seconds). DCS or network issues shorter than this will not cause Patroni to demote the leader
  • Default: 10
patroni_bootstrap_dcs_maximum_lag_on_failover
  • Description: Maximum bytes a follower may lag to be able to participate in leader election
  • Default: 1048576
patroni_bootstrap_dcs_master_start_timeout
  • Description: Amount of time a master is allowed to recover from failures before failover is triggered (in seconds). Default is 300 seconds. When set to 0 failover is done immediately after a crash is detected if possible. When using asynchronous replication a failover can cause lost transactions. Worst case failover time for master failure is: loop_wait + master_start_timeout + loop_wait, unless master_start_timeout is zero, in which case it's just loop_wait. Set the value according to your durability/availability tradeoff
  • Default: 300
patroni_bootstrap_dcs_synchronous_mode
  • Description: Turns on synchronous replication mode. In this mode a replica will be chosen as synchronous and only the latest leader and synchronous replica are able to participate in leader election. Synchronous mode makes sure that successfully committed transactions will not be lost at failover, at the cost of losing availability for writes when Patroni cannot ensure transaction durability. See replication modes documentation for details
  • Default: false
patroni_bootstrap_dcs_synchronous_mode_strict
  • Description: Prevents disabling synchronous replication if no synchronous replicas are available, blocking all client writes to the master. See replication modes documentation for details
  • Default: false
patroni_bootstrap_dcs_check_timeline
  • Description: By default, when running leader elections, Patroni does not take into account the current timeline of replicas, what in some cases could be undesirable behavior. You can prevent the node not having the same timeline as a former master become the new leader by changing the value of check_timeline parameter to true. It could happen that the node is considering itself as a healthiest one although it is currently not on the latest known timeline. In some cases we want to avoid promoting of such node, which could be achieved by setting check_timeline parameter to true (default behavior remains unchanged)
  • Default: false
patroni_bootstrap_dcs_standby_cluster
  • Description: List of settings to bootstrap a standby cluster
  • Default:
- { option: "host",                     value: "" } 
- { option: "port",                     value: "" }
- { option: "primary_slot_name",        value: "" }
- { option: "create_replica_methods",   value: "" }
- { option: "restore_command",          value: "" }
- { option: "archive_cleanup_command",  value: "" }
- { option: "recovery_min_apply_delay", value: "" }
patroni_bootstrap_dcs_postgresql_use_pg_rewind
  • Description: Whether or not to use pg_rewind on the former leader when it joins cluster as a replica
  • Default: false
patroni_bootstrap_dcs_postgresql_use_slots
  • Description: Whether or not to use replication slots
  • Default: true
patroni_bootstrap_dcs_postgresql_parameters
  • Description: List of PostgreSQL configuration settings (GUCs) which will be stored in a DCS and later could be changed via patronictl edit-config
  • Default:
- { option: "max_connections",           value: "100" }
- { option: "max_locks_per_transaction", value: "64" }
- { option: "max_worker_processes",      value: "8" }
- { option: "max_prepared_transactions", value: "0" }
- { option: "wal_level",                 value: "replica" }
- { option: "wal_log_hints",             value: "on" }
- { option: "track_commit_timestamp",    value: "off" }
- { option: "max_wal_senders",           value: "10" }
- { option: "max_replication_slots",     value: "10" }
- { option: "wal_keep_segments",         value: "8" }
patroni_bootstrap_dcs_postgresql_recovery_conf
  • Description: List of additional configuration settings written to recovery.conf when configuring follower. There is no recovery.conf anymore in PostgreSQL 12, but you may continue using this section, because Patroni handles it transparently
  • Default: []
patroni_bootstrap_dcs_postgresql_pg_hba
  • Description: List of lines that you should add to pg_hba.conf which will be stored in a DCS and later could be changed via patronictl edit-config
  • Default: []
patroni_bootstrap_dcs_slots
  • Description: Defines permanent replication slots. These slots will be preserved during switchover/failover. Patroni will try to create slots before opening connections to the cluster
  • Default: []
patroni_bootstrap_method_name
patroni_bootstrap_method_command
patroni_bootstrap_method_keep_existing_recovery_conf
  • Description: Whether or not to remove the existing recovery.conf file if it exists. This is useful when bootstrapping from a backup with tools like pgBackRest that generate the appropriate recovery.conf for you
  • Default: false
patroni_bootstrap_method_recovery_conf
  • Description: List of additional configuration settings written to recovery.conf. If enabled, Patroni will generate a recovery.conf before starting the newly bootstrapped instance. Typically, such recovery.conf should contain at least one of the recovery_target_* parameters, together with the recovery_target_timeline set to promote
  • Default: []
patroni_bootstrap_initdb
  • Description: List options to be passed on to initdb
  • Default:
- { option: "encoding", value: "UTF8" }
- { option: "data-checksums" }
patroni_bootstrap_pg_hba
  • Description: List of lines that you should add to pg_hba.conf
  • Default: []
patroni_bootstrap_post_bootstrap
  • Description: Path to a script that will be executed after initializing the cluster. The script receives a connection string URL (with the cluster superuser as a user name). The PGPASSFILE environment variable is set to the location of pgpass file
  • Default: ""
patroni_bootstrap_post_init
  • Description: Path to a script that will be executed after initializing the cluster. The script receives a connection string URL (with the cluster superuser as a user name). The PGPASSFILE environment variable is set to the location of pgpass file
  • Default: ""
patroni_bootstrap_users
  • Description: List of additional users along with their passwords and CREATE USER options which need to be created after initializing new cluster
  • Default:
- {
    name: "{{ patroni_superuser_username }}",
    password: "{{ patroni_superuser_password }}",
    options: []
  }
- {
    name: "{{ patroni_replication_username }}",
    password: "{{ patroni_replication_password }}",
    options: ['replication']
  }
patroni_postgresql_use_unix_socket
  • Description: Specifies that Patroni should prefer to use unix sockets to connect to the cluster. If unix_socket_directories is defined, Patroni will use the first suitable value from it to connect to the cluster and fallback to tcp if nothing is suitable. If unix_socket_directories is not specified in postgresql.parameters, Patroni will assume that the default value should be used and omit host from the connection parameters
  • Default: true
patroni_postgresql_listen
  • Description: IP address + port that Postgres listens to; must be accessible from other nodes in the cluster, if you’re using streaming replication. Multiple comma-separated addresses are permitted, as long as the port component is appended after to the last one with a colon, i.e. listen: 127.0.0.1,127.0.0.2:5432. Patroni will use the first address from this list to establish local connections to the PostgreSQL node
  • Default: 0.0.0.0:5432
patroni_postgresql_connect_address
  • Description: IP address + port through which Postgres is accessible from other nodes and applications
  • Default: {{ ansible_host }}:5432
patroni_postgresql_authentication
  • Description: List of users which will be created during initialization and later used by Patroni to connect to the postgres, access master via streaming replication and execute pg_rewind
  • Default:
- {
    type: "superuser",
    username: "{{ patroni_superuser_username }}",
    password: "{{ patroni_superuser_password }}"
  }
- {
    type: "replication", 
    username: "{{ patroni_replication_username }}",
    password: "{{ patroni_replication_password }}"
  }
patroni_postgresql_callbacks
  • Description: List of callback scripts which should be present on the postgres node to run on certain actions. Patroni will pass the action, role and cluster name as an arguments
  • Default:
- { event: "on_reload", script: "" }
- { event: "on_restart", script: "" }
- { event: "on_role_change", script: "" }
- { event: "on_start", script: "" }
- { event: "on_stop", script: "" }
patroni_postgresql_create_replica_methods
  • Description: An ordered list of the create methods for turning a Patroni node into a new replica. "basebackup" is the default method; other methods are assumed to refer to scripts, each of which is configured as its own config item. See custom replica creation methods documentation for further explanation
  • Default: ['basebackup']
patroni_postgresql_pgbackrest
  • Description: List of pgBackRest method specific options
  • Default: []
patroni_postgresql_wal_e
  • Description: List of WAL-E method specific options
  • Default: []
patroni_postgresql_basebackup
  • Description: List of pg_basebackup method specific options
  • Default: []
patroni_postgresql_recovery_conf
  • Description: List of additional configuration settings written to recovery.conf when configuring follower
  • Default: []
patroni_postgresql_custom_conf
  • Description: Path to an optional custom postgresql.conf file, that will be used in place of postgresql.base.conf. The file must exist on all cluster nodes, be readable by PostgreSQL and will be included from its location on the real postgresql.conf. Note that Patroni will not monitor this file for changes, nor backup it. However, its settings can still be overridden by Patroni’s own configuration facilities - see dynamic configuration for details
  • Default: ""
patroni_postgresql_parameters
  • Description: List of PostgreSQL configuration settings (GUCs)
  • Default: [{ option: "unix_socket_directories", value: "/var/run/postgresql" }]
patroni_postgresql_pg_hba
  • Description: List of lines that Patroni will use to generate pg_hba.conf. This parameter has higher priority than {{ patroni_bootstrap_pg_hba }}
  • Default: []
patroni_postgresql_pg_ctl_timeout
  • Description: How long should pg_ctl wait when doing start, stop or restart
  • Default: 60
patroni_postgresql_remove_data_directory_on_rewind_failure
  • Description: If this option is enabled, Patroni will remove the PostgreSQL data directory and recreate the replica. Otherwise it will try to follow the new leader
  • Default: false
patroni_postgresql_remove_data_directory_on_diverged_timelines
  • Description: Patroni will remove the PostgreSQL data directory and recreate the replica if it notices that timelines are diverging and the former master can not start streaming from the new master. This option is useful when pg_rewind can not be used
  • Default: false
patroni_watchdog_mode
  • Description: Possible values are off, automatic or required. When off watchdog is disabled. When automatic watchdog will be used if available, but ignored if it is not. When required the node will not become a leader unless watchdog can be successfully enabled
  • Default: automatic
patroni_watchdog_device
  • Description: Path to watchdog device
  • Default: /dev/watchdog
patroni_watchdog_safety_margin
  • Description: Number of seconds of safety margin between watchdog triggering and leader key expiration
  • Default: 5
patroni_tags
  • Description: List of Patroni tags to assign to the current cluster member
  • Default:
- { name: "nofailover",    value: "false" }
- { name: "noloadbalance", value: "false" }
- { name: "clonefrom",     value: "false" }
- { name: "nosync",        value: "false" }
- { name: "replicatefrom", value: "" }
Clone this wiki locally