Forge Home

csync2

Manage the cluster software Csync2

2,175 downloads

1,603 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 0.2.0 (latest)
  • 0.1.1
  • 0.1.0
released Jul 27th 2020
This version is compatible with:
  • Puppet Enterprise 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2016.4.x
  • Puppet >= 4.10.10 < 7.0.0
  • , , ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'lbetz-csync2', '0.2.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add lbetz-csync2
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install lbetz-csync2 --version 0.2.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

lbetz/csync2 — version 0.2.0 Jul 27th 2020

csync2

Table of Contents

  1. Description
  2. Setup - The basics of getting started with csync2
  3. Usage - Configuration options and additional functionality
  4. Reference

Description

Csync2 is a cluster synchronization tool. It can be used to keep files on multiple hosts in a cluster in sync. Csync2 can handle complex setups with much more than just 2 hosts, handle file deletions and can detect conflicts.

The module configures Csync2 and optionally installs the package from an preconfigured repository. For RHEL/CentOS the module is prepared to use package from Okay.

Setup

Setup Requirements

This module supports:

  • [puppet] >= 4.10 < 7.0.0

And requires the following modules:

Beginning with csync2

Add this declaration to your Puppetfile:

mod 'csync2',
  :git => 'https://github.com/lbetz/puppet-csync2.git',
  :tag => 'v0.1.0'

Then run:

bolt puppetfile csync2

Or do a git clone by hand into your modules directory:

git clone https://github.com/lbetz/puppet-csync2.git csync2

Change to csync2 directory and check out your desired version:

cd csync2
git checkout v0.1.0

Usage

By default the module only configures Csync2 to install the software a preconfigured repository ia needed.

Software Installation

Declaration will manage a package named 'csync2'.

On RHEL/CentOS 7:

package { 'epel-release':
  ensure => installed,
}

package { 'okay-release-1-3':
  ensure   => installed.
  provider => 'rpm',
  source   => 'http://repo.okay.com.mx/centos/7/x86_64/release/okay-release-1-3.el7.noarch.rpm'
}

class { 'csync2': }

To fix a bug in the package and add a missing link for using sqlite3, you've to add the followingto your code right behind package management:

file { '/usr/lib64/libsqlite3.so':
  ensure => link,
  target => '/usr/lib64/libsqlite3.so.0',
}

Certificate

Certificate and private key can be managed by using base64 encoded strings:

class { 'csync2':
  ssl_cert => '-----BEGIN CERTIFICATE----- ...',
  ssl_key  => '----BEGIN RSA PRIVATE KEY----- ...',
}

Or can be handeld before declaring 'csync2'.

Configuring syncing groups

To sync the config file itself between two nodes:

class { 'csync2':
  groups => {
    'cluster' => {
      hosts  => ['node1.example.org', 'node2.example.org'],
      blocks => [{
        'includes' => [ '/etc/csync2.cfg' ],
      }],
      key    => 'supersecret',
    },
  },
}

A more complex example with two blocks:

csync2::group { 'monitoring':
  hosts  => ['node1.example.org', 'node2.example.org'],
  blocks => [
    {
      'includes' => [ '/etc/icinga2/features-available', '/etc/icinga2/features-enabled' ],
      'actions'  => [
        {
          'pattern' => [ '/etc/icinga2/features-enabled/*' ],
          'exec'    => [ 'systemctl reload icinga2' ],
          'logfile' => '/var/log/csync2_action.log',
          'do'      => 'do-local',
        },
      ],
    },
    {
      'includes' => [ '/etc/icingaweb2' ],
      'excludes' => [ '/etc/icingaweb2/modules/director', '/etc/icingaweb2/enabledModules/director' ],
    },
  ],
  key    => 'supersecret',
}

Cronjob

To trigger the sync a cronjob is needed:

include csync2

cron { 'csync2':
  command => "${::csync2::globals::csync2_bin} -x",
  user    => 'root',
}

xinetd instead of systemd

You're able to use a xinetd instead of systemd service. If you do so, the port parameter hasn't any impact.

class { 'csync2':
  ensure => stopped,
  enable => false,
}

file { '/etc/xinetd.d/csync2':
  ensure  => file,
  content => "service csync2
{
        flags           = REUSE
        socket_type     = stream
        wait            = no
        user            = root
        group           = root
        server          = ${::csync2::globals::csync2_bin}
        server_args     = -i -l
        #log_on_failure += USERID
        disable         = no
        # only_from     = 192.168.199.3 192.168.199.4
}",
  owner  => 'root',
  mode   => '0644',
}

package { 'xinetd':
  ensure => installed,
  before => Service['xinetd'],
}

service { 'xinetd':
  ensure    => running,
  enable    => true,
  subscribe => File['/etc/xinetd.d/csync2'],
}

Maybe it's a better idea to use the puppetlabs/xinetd module to install, configure and manage xinetd.

Reference

See REFERENCE.md