Skip to content

About

puppet module for any-sync-* daemons

Resources

Code of conduct

Contributing

Security policy

Stars

10 stars

Watchers

3 watching

Forks

Repository files navigation

Puppet for any-sync

https://tech.anytype.io/

Puppet module that installs, configures and runs self-hosted any-sync daemons: any-sync-node, any-sync-filenode, any-sync-coordinator, any-sync-consensusnode and any-ns-node.

Table of Contents

  1. Requirements
  2. Setup
  3. Usage
  4. Reference
  5. Contribution

Requirements

  • Puppet 7, RPM-based OS (packages are downloaded as .rpm from GitHub releases)
  • MongoDB >= 4 in Replica Set mode — for coordinator, consensusnode and ns
  • Redis with the Bloom module — for filenode
  • S3-compatible storage (AWS S3, Garage, etc.) — for filenode

Puppet modules:

Setup

Versions

Default package versions are pinned in data/common.yaml (pkg::* keys) and can be overridden in your hiera. Compatible version sets:

Secrets

Example hiera configuration

Every daemon is disabled by default; enable the ones you need per host group. Defaults for each daemon live in data/common/.

---
classes:
  - anysync

# enable for relevant group of hosts {{
anysync::consensusnode: true
anysync::coordinator: true
anysync::filenode: true
anysync::node: true
# }}

github_token: <secret> # used to download release packages

anysync::filenode::config::cfg:
  s3Store:
    region: eu-central-1
    profile: default
    bucket: s3BucketName
    maxThreads: 16
  redis:
    isCluster: true
    url: redis://redis1.local:6379?dial_timeout=3&read_timeout=6s&addr=redis1.local:6380&addr=redis2.local:6379&addr=redis2.local:6380&addr=redis3.local:6379&addr=redis3.local:6380

anysync::filenode::config::aws_credentials:
  default:
    aws_access_key_id: <secret>
    aws_secret_access_key: <secret>

anysync::coordinator::config::cfg:
  mongo:
    connect: mongodb://coordinator-db1.local:27017,coordinator-db2.local:27017,coordinator-db3.local:27017

anysync::consensusnode::config::cfg:
  mongo:
    connect: mongodb://coordinator-db1.local:27017,coordinator-db2.local:27017,coordinator-db3.local:27017/?w=majority # "w=majority" is required!

# keys of every node, picked by hostname
any_sync_accounts:
  # tree nodes {{
  node1.local:
    peerId: 12D3KooWLTVK3VgXziU8ZcvvHUebueSBPiJNjXBxm3DQWtqsCbWD
    peerKey: <secret>
    signingKey: <secret>
  node2.local:
    peerId: 12D3KooWBTWo5KVveQuVEA4VeivgbS7LxGkTgmWspEtpaw3D5xXw
    peerKey: <secret>
    signingKey: <secret>
  node3.local:
    peerId: 12D3KooWF8HJnjL8MDUAExyg7yEAXhcXKzMwsn3dvivDjKWe7NN5
    peerKey: <secret>
    signingKey: <secret>
  # }}
  filenode1.local:
    peerId: 12D3KooWJExfEKskv47BP77mrBV2ciCgZgkdZFrL5R1CQjU6DVb6
    peerKey: <secret>
    signingKey: <secret>
  coordinator1.local:
    peerId: 12D3KooWRjnz8Ju1hFmY6SzoVYKXBVtqiQXGJkqQesQaRMpF2sVF
    peerKey: <secret>
    signingKey: <secret> # network signingKey
  consensusnode1.local:
    peerId: 12D3KooWBjCiYhk31PhdjG72M9oQKMbcyC3adsMbT7tMrmTi8KeB
    peerKey: <secret>
    signingKey: <secret> # network signingKey

# network config shared by all daemons
any_sync_network:
  networkId: N5787WrcATL3f9kDUVxz9yeexEoxxmBLQRhJ47SBNBXEhadc
  nodes:
    - peerId: 12D3KooWLTVK3VgXziU8ZcvvHUebueSBPiJNjXBxm3DQWtqsCbWD
      addresses: [node1.local:443, quic://node1.local:5430]
      types: [tree]
    - peerId: 12D3KooWBTWo5KVveQuVEA4VeivgbS7LxGkTgmWspEtpaw3D5xXw
      addresses: [node2.local:443, quic://node2.local:5430]
      types: [tree]
    - peerId: 12D3KooWF8HJnjL8MDUAExyg7yEAXhcXKzMwsn3dvivDjKWe7NN5
      addresses: [node3.local:443, quic://node3.local:5430]
      types: [tree]
    - peerId: 12D3KooWJExfEKskv47BP77mrBV2ciCgZgkdZFrL5R1CQjU6DVb6
      addresses: [filenode1.local:443, quic://filenode1.local:5430]
      types: [file]
    - peerId: 12D3KooWRjnz8Ju1hFmY6SzoVYKXBVtqiQXGJkqQesQaRMpF2sVF
      addresses: [coordinator1.local:443, quic://coordinator1.local:5430]
      types: [coordinator]
    - peerId: 12D3KooWBjCiYhk31PhdjG72M9oQKMbcyC3adsMbT7tMrmTi8KeB
      addresses: [consensusnode1.local:443, quic://consensusnode1.local:5430]
      types: [consensus]

Usage

First deploy

The order matters: the coordinator must know the network before other daemons connect to it.

  1. Prepare dependencies. MongoDB replica set, Redis with Bloom, S3 bucket and credentials.
  2. Generate the network. With any-sync-network create the network and nodes (at least 3 tree, 1 coordinator, 1 file, 1 consensus). Put keys into any_sync_accounts, nodes into any_sync_network, and keep the generated client.yml for clients. The coordinator and consensusnode use the network signingKey.
  3. Deploy the coordinator. Run puppet on the coordinator hosts. It writes /etc/any-sync-coordinator/config.yml and network.yml and starts the service.
  4. Apply the network config to Mongo. On a coordinator host, once:
    any-sync-confapply -c /etc/any-sync-coordinator/config.yml -n /etc/any-sync-coordinator/network.yml -e
    
  5. Deploy the other daemons. Run puppet on the tree nodes, consensusnode and filenode hosts (any order).
  6. Check connectivity. Run any-sync-netcheck with client.yml.
  7. Connect clients. Import client.yml into the Anytype app, see self-hosting docs.

Changing the network (adding nodes, changing addresses)

  1. Update any_sync_accounts / any_sync_network in hiera.
  2. Run puppet on the coordinator, then run any-sync-confapply again.
  3. Run puppet on the rest of the hosts.
  4. Give clients the updated client.yml.

Upgrading

  1. Pick a version set from compatible versions and update pkg::* keys.
  2. Roll out: coordinator first, then consensusnode, filenode and tree nodes one by one.

Show current network config in Mongo

mongosh coordinator --eval 'db.getMongo().setReadPref("primaryPreferred"); db.nodeConf.find().sort( { _id: -1 } ).limit(1)'

Reference

All classes and parameters are documented in REFERENCE.md. To regenerate it:

puppet strings generate --format markdown

Contribution

Thank you for your desire to develop Anytype together!

❤️ This project and everyone involved in it is governed by the Code of Conduct.

🧑‍💻 Check out our contributing guide to learn about asking questions, creating issues, or submitting pull requests.

🫢 For security findings, please email security@anytype.io and refer to our security guide for more information.

🤝 Follow us on Github and join the Contributors Community.


Made by Any — a Swiss association 🇨🇭

Licensed under MIT.

About

puppet module for any-sync-* daemons

Resources

Code of conduct

Contributing

Security policy

Stars

10 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages