Giter VIP home page Giter VIP logo

ansible-postgresql_replication's Introduction

enix.postgresql_replication

A role for deploying and configuring postgresql replication cluster on unix hosts using Ansible.

Requirements

Supported targets:

  • Debian 8 "Jessie"
  • Debian 9 "Stretch"

Role Variables

This roles comes preloaded with almost every available default. You can override each one in your hosts/group vars, in your inventory, or in your play. See the annotated defaults in defaults/main.yml for help in configuration. All provided variables start with postgresql_replication__.

This role work in a different way than several others in a way that in order to make different cluster hosts roles independent we use ansible groups. There is so 3 different groups to define in your inventory. to make this usable with different clusters in the same inventory they are configurable.

  • postgresql_replication__group - the main group of hosts for this cluster, default: postgresql
  • postgresql_replication__group_master - the master group that must include only one host, default: postgresql_master
  • postgresql_replication__group_replicas - the group including the replicas hosts, default: postgresql_replicas Your inventory must have in final this form (yaml format exemple):
all:
  children:
    postgresql:
      children:
        postgresql_master:
          hosts:
            db-01:
              ansible_host: 185.145.251.12
        postgresql_replicas:
          hosts:
            db-02:
              ansible_host: 185.145.251.243
  • postgresql_replication__user - the username to use for authentification of replication nodes. default : replicate.
  • postgresql_replication__password - the postgresql_replication__user password. It is important to change default on production clusters. default: replicate.
  • postgresql_replication__waldir - Directory used to store WAL file sent from the master node to the replication nodes.

Sending servers configuration. See (https://www.postgresql.org/docs/11/runtime-config-replication.html#RUNTIME-CONFIG-REPLICATION-SENDER) for details of correct values for your setup.

  • postgresql_replication__walsenders - Number of wal sender processes to enable. default : 3.

  • postgresql_replication__walsegments - Number of wal segments to keep (16MB each). default: 64.

  • postgresql_replication__trigger_file - File used to trigger master operation on a slave node. default: /tmp/MasterNow

  • postgresql_replication__bootstrap - Very important. when this variable is set to "yesiwant" the deployement will remove all datas on hosts defined in postgresql_replication__group_replicas and proceed with a fresh pg_basebackup from the master. Take care as if you enable this and do not properly setup hosts in groups you can completely destroy you datas.

Dependencies

Usage

Use Ansible galaxy requirements.yml

- src: enix.postgresql_replication

And add it to your play's roles:

- hosts: postgresql
  roles:
    - role enix.postgresql_replication:
        postgresql__version: 11
        postgresql__global_config_options:
          - option: listen_addresses
            value: '*'
          - option: log_min_duration_statement
            value: 1000
        postgresql__hba_entries:
          - {type: local, database: all, user: postgres, auth_method: peer}
          - {type: local, database: all, user: all, auth_method: peer}
          - {type: host, database: all, user: all, address: "0.0.0.0/0", auth_method: md5}
          - {type: hostssl, database: replication, user: "{{ postgresql_replication__user }}", address: "0.0.0.0/0" ,auth_method: md5}
        postgresql__users:
          - {name: "{{ postgresql_replication__user }}", password: "{{ postgresql_replication__password }}", role_attr_flags: "REPLICATION"}

You can also use the role as a playbook. You will be asked which hosts to provision, and you can further configure the play by using --extra-vars.

$ ansible-playbook -i inventory --extra-vars='{...}' main.yml

Still to do

  • Add real gitlab / travis CI
  • Add tests using molecule

Changelog

1.1.0

Update group names to postgresql_master and postgresql_replicas. Comply with ansible 2.8+ group names requirements

1.0.0

Initial version.

License

GPLv2

Author Information

Laurent CORBES [email protected] - http://www.enix.io

ansible-postgresql_replication's People

Contributors

kmonticolo avatar lcaflc avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-postgresql_replication's Issues

Deprecation warning: TRANSFORM_INVALID_GROUP_CHARS

With dashes instead of underscores in group names Ansible 2.8 complains about deprecation warning:

[DEPRECATION WARNING]: The TRANSFORM_INVALID_GROUP_CHARS settings is set to allow bad characters in group names by default, this will change, but still be user configurable on deprecation. This feature will be removed in version 2.10. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.