├── .github └── workflows │ ├── cla.yml │ └── release.yml ├── .gitignore ├── LICENSE.md ├── README.md ├── any-sync.yml ├── galaxy.yml ├── group_vars └── any_sync.yml ├── inventory.ini ├── meta └── runtime.yml └── roles ├── any_sync_consensusnode ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ ├── config.yml │ ├── install.yml │ ├── main.yml │ └── service.yml └── templates │ ├── config.yml.j2 │ └── service.j2 ├── any_sync_coordinator ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ ├── config.yml │ ├── install.yml │ ├── main.yml │ └── service.yml └── templates │ ├── config.yml.j2 │ ├── network.yml.j2 │ └── service.j2 ├── any_sync_filenode ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ ├── config.yml │ ├── install.yml │ ├── main.yml │ └── service.yml └── templates │ ├── aws_credentials.j2 │ ├── config.yml.j2 │ └── service.j2 └── any_sync_node ├── README.md ├── defaults └── main.yml ├── handlers └── main.yml ├── meta └── main.yml ├── tasks ├── config.yml ├── install.yml ├── main.yml └── service.yml └── templates ├── config.yml.j2 └── service.j2 /.github/workflows/cla.yml: -------------------------------------------------------------------------------- 1 | name: "CLA Check" 2 | on: 3 | issue_comment: 4 | types: [created] 5 | pull_request_target: 6 | types: [opened,closed,synchronize] 7 | 8 | permissions: 9 | actions: write 10 | contents: write 11 | pull-requests: write 12 | statuses: write 13 | 14 | jobs: 15 | cla-check: 16 | uses: anyproto/open/.github/workflows/cla.yml@main 17 | secrets: inherit -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | tags: 4 | - '*.*.*' 5 | 6 | name: Publish release on GH and Ansible Galaxy 7 | 8 | permissions: write-all 9 | 10 | jobs: 11 | create_release: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout code 15 | uses: actions/checkout@v4.1.1 16 | 17 | - name: Set up Python3 18 | uses: actions/setup-python@v5 19 | with: 20 | python-version: '3.x' 21 | 22 | - name: Install Ansible. 23 | run: pip3 install ansible-core 24 | 25 | - name: Update version for galaxy 26 | run: | 27 | sed -i "s/%VERSION%/${{ github.ref_name }}/g" galaxy.yml 28 | 29 | - name: Trigger a new import on Galaxy. 30 | run: | 31 | ansible-galaxy collection build 32 | ansible-galaxy collection publish --api-key ${{ secrets.GALAXY_API_KEY }} ./mighty_sponge-any_sync-${{ github.ref_name }}.tar.gz 33 | 34 | - name: Create GH Release 35 | uses: softprops/action-gh-release@v0.1.15 36 | with: 37 | generate_release_notes: true 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ansible.cfg 2 | test.ini 3 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Any Association 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 19 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 21 | OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ansible-anysync 2 | 3 | - [Getting Started](#getting-started) 4 | - [Prerequisites](#prerequisites) 5 | - [Installing](#installing) 6 | - [Usage](#usage) 7 | - [Contribution](#contribution) 8 | 9 | ## Getting Started 10 | 11 | Ansible role for any-sync daemons. Currently, this works on Debian and RHEL based linux systems. Tested platforms are: 12 | * Ubuntu 22.04 13 | * Amazon Linux 2 14 | 15 | You can read the documentation on using any-sync [here](https://tech.anytype.io/). 16 | 17 | ### Prerequisites 18 | 19 | * Minimum Ansible v2.11 recommended 20 | * **x1** [Redis with Bloom module](https://github.com/RedisBloom/RedisBloom) 21 | * **x1-3** MongoDB (version ≥6 recommended) in Replica Set mode 22 | * S3 object storage: AWS S3 or self-hosted solution (for example [minio](https://github.com/minio/minio)) 23 | 24 | ### Installing 25 | 26 | Clone the current repository with roles 27 | 28 | ``` 29 | git clone https://github.com/anyproto/ansible-anysync.git 30 | ``` 31 | 32 | Use the playbook: 33 | 34 | ``` 35 | ansible-playbook any-sync.yml -i inventory.ini 36 | ``` 37 | 38 | ## Usage 39 | 40 | 1. Define the structure of your any-sync cluster in the `inventory.ini` file. Minimum **x3 any-sync-node and x1 nodes of other types**, and also **x1 Redis** and **x1-3 MongoDB** in Replica Set mode. If not using AWS S3, specify **Minio server** address. 41 | 2. Generate using [any-sync-tools](https://github.com/anyproto/any-sync-tools/blob/main/any-sync-network/README.md) and then copy `networkId`(from client.yml file) of your network and `peerId, peerKey, signingKey` for each any-sync-* account. Paste this data into the `group_vars/any_sync.yml` file on the appropriate lines, replacing example data. 42 | 3. You can then make configuration changes to each any-sync-* daemon by editing the corresponding `default/main.yml` within each role. The latest production versions of any-sync components are available [here](https://puppetdoc.anytype.io/api/v1/prod-any-sync-compatible-versions/). Remember to change the MongoDB and Redis URLs if required. 43 | 4. Import into your client app `client.yml` file that you should have created during generation in step 2. 44 | 45 | ## Contribution 46 | Thank you for your desire to develop Anytype together! 47 | 48 | ❤️ This project and everyone involved in it is governed by the [Code of Conduct](https://github.com/anyproto/.github/blob/main/docs/CODE_OF_CONDUCT.md). 49 | 50 | 🧑‍💻 Check out our [contributing guide](https://github.com/anyproto/.github/blob/main/docs/CONTRIBUTING.md) to learn about asking questions, creating issues, or submitting pull requests. 51 | 52 | 🫢 For security findings, please email [security@anytype.io](mailto:security@anytype.io) and refer to our [security guide](https://github.com/anyproto/.github/blob/main/docs/SECURITY.md) for more information. 53 | 54 | 🤝 Follow us on [Github](https://github.com/anyproto) and join the [Contributors Community](https://github.com/orgs/anyproto/discussions). 55 | 56 | --- 57 | Made by Any — a Swiss association 🇨🇭 58 | 59 | Licensed under [MIT](./LICENSE.md). 60 | -------------------------------------------------------------------------------- /any-sync.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Deploy any-sync-coordinator 3 | hosts: any_sync_coordinator 4 | become: true 5 | roles: 6 | - any_sync_coordinator 7 | 8 | - name: Deploy any-sync-node 9 | hosts: any_sync_node 10 | become: true 11 | roles: 12 | - any_sync_node 13 | 14 | - name: Deploy any-sync-consensusnode 15 | hosts: any_sync_consensusnode 16 | become: true 17 | roles: 18 | - any_sync_consensusnode 19 | 20 | - name: Deploy any-sync-filenode 21 | hosts: any_sync_filenode 22 | become: true 23 | roles: 24 | - any_sync_filenode 25 | -------------------------------------------------------------------------------- /galaxy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | namespace: mighty_sponge 3 | name: any_sync 4 | 5 | version: %VERSION% 6 | readme: README.md 7 | authors: 8 | - anyproto 9 | 10 | description: Ansible roles for deploy any-sync-* daemons. 11 | 12 | license_file: LICENSE.md 13 | 14 | tags: 15 | - any_sync 16 | - any_sync_node 17 | - any_sync_consensusnode 18 | - any_sync_coordinator 19 | - any_sync_filenode 20 | 21 | repository: https://github.com/anyproto/ansible-anysync 22 | documentation: https://github.com/anyproto/ansible-anysync 23 | issues: https://github.com/anyproto/ansible-anysync/issues 24 | -------------------------------------------------------------------------------- /group_vars/any_sync.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | any_sync_node_yamux_port: 1001 4 | any_sync_node_quic_port: 2001 5 | 6 | any_sync_coordinator_yamux_port: 1002 7 | any_sync_coordinator_quic_port: 2002 8 | 9 | any_sync_filenode_yamux_port: 1003 10 | any_sync_filenode_quic_port: 2003 11 | 12 | any_sync_consensusnode_yamux_port: 1004 13 | any_sync_consensusnode_quic_port: 2004 14 | 15 | any_sync_config: 16 | networkId: "N6jGqb6SfHa3aENsCjvnSMXFR9F3eZUhCCziqs28rkUyJRWw" 17 | 18 | any-sync-node1: 19 | peerId: 12D3KooWRyBw2GnQskP8kUFD91Ja46ecfa33VXs8mcjVv3N4T1dQ 20 | peerKey: ixxHUiWSGpLJvP3b2NA9os8qjNQYe75YXKVAmfTdidfv/aTAoEZ0F9brWQtS51BqX5vxq6l0beq0e1TYgiSSnw== 21 | signingKey: ixxHUiWSGpLJvP3b2NA9os8qjNQYe75YXKVAmfTdidfv/aTAoEZ0F9brWQtS51BqX5vxq6l0beq0e1TYgiSSnw== 22 | type: tree 23 | addresses: 24 | - "{{ hostvars['any-sync-node1'].ansible_host }}:{{ any_sync_node_yamux_port }}" 25 | - "quic://{{ hostvars['any-sync-node1'].ansible_host }}:{{ any_sync_node_quic_port }}" 26 | 27 | any-sync-node2: 28 | peerId: 12D3KooWQ21pt8h1UJCiKSYSMqEgu1PTVcfPyjRf1neHzT4Yjzde 29 | peerKey: Oy3wc92EiAk9/7QuGKCGjQzjm8NPv3lLrCM2rC3s3IzS/5XcnLOu69qYTnu3HfsNOx6nSS1jtNhLYCCbPTvUsQ== 30 | signingKey: Oy3wc92EiAk9/7QuGKCGjQzjm8NPv3lLrCM2rC3s3IzS/5XcnLOu69qYTnu3HfsNOx6nSS1jtNhLYCCbPTvUsQ== 31 | type: tree 32 | addresses: 33 | - "{{ hostvars['any-sync-node2'].ansible_host }}:{{ any_sync_node_yamux_port }}" 34 | - "quic://{{ hostvars['any-sync-node2'].ansible_host }}:{{ any_sync_node_quic_port }}" 35 | 36 | any-sync-node3: 37 | peerId: 12D3KooWRy6YsEMBgqi5uzseug3dJsq5iFBbQmRsMyXmDPDbFS7j 38 | peerKey: euJieFMweIDeIbIjNJLFJn6tJiJRoyPRNk3NDN7wOi/v947g6seIzlKHDx+QeXK/5TsABnX5hCbi3CcEUZdXWg== 39 | signingKey: euJieFMweIDeIbIjNJLFJn6tJiJRoyPRNk3NDN7wOi/v947g6seIzlKHDx+QeXK/5TsABnX5hCbi3CcEUZdXWg== 40 | type: tree 41 | addresses: 42 | - "{{ hostvars['any-sync-node3'].ansible_host }}:{{ any_sync_node_yamux_port }}" 43 | - "quic://{{ hostvars['any-sync-node3'].ansible_host }}:{{ any_sync_node_quic_port }}" 44 | 45 | any-sync-coordinator1: 46 | peerId: 12D3KooWRqFJtDMstqtcYAKZYEuGksD8A5WTHJZsFFk5beyrCVsq 47 | peerKey: NPJc2soR53KQE9llBMdFnOO9kgTF2kwPXJ9e0xVBND/t9NC80zaSo3cMMKCI8Hp7MMFHvBIyYRJyes6ao6LMfA== 48 | signingKey: "lrX4yWqQmHyN1zNh/tCz0h+53V2RJ4CtH3mbsK30jihz/yJuhULdvayk0WkpQv5GSm7Q408zKlkO0b+yblazpg==" 49 | type: coordinator 50 | addresses: 51 | - "{{ hostvars['any-sync-coordinator1'].ansible_host }}:{{ any_sync_coordinator_yamux_port }}" 52 | - "quic://{{ hostvars['any-sync-coordinator1'].ansible_host }}:{{ any_sync_coordinator_quic_port }}" 53 | 54 | any-sync-filenode1: 55 | peerId: 12D3KooWCHZk6EwaYtAFS81pGrn1t5CCgBtTVKSxzuJkLYix8zwQ 56 | peerKey: x0iUgSGBqiyKBvlQl3T+LDaAwSA6J1Z/ebrCtuFawegkryS+P9tv/G7D/g3rwoFSaL4yz8G8eyElG/KhmiXLvw== 57 | signingKey: x0iUgSGBqiyKBvlQl3T+LDaAwSA6J1Z/ebrCtuFawegkryS+P9tv/G7D/g3rwoFSaL4yz8G8eyElG/KhmiXLvw== 58 | type: file 59 | addresses: 60 | - "{{ hostvars['any-sync-filenode1'].ansible_host }}:{{ any_sync_filenode_yamux_port }}" 61 | - "quic://{{ hostvars['any-sync-filenode1'].ansible_host }}:{{ any_sync_filenode_quic_port }}" 62 | 63 | any-sync-consensusnode1: 64 | peerId: 12D3KooWG52DEyA8hk4UbdzEnfPfyBZ1MLjcN2Ts7cDQkoYHo1U1 65 | peerKey: 5rbynfEBmolXGZf6pqJAMQmo2yFR+tS9Wj4XmUHqeEtc50Svnt4VnYceL1H72NHNIB+UsJbHHOBpMgNGtHh2rg== 66 | signingKey: lrX4yWqQmHyN1zNh/tCz0h+53V2RJ4CtH3mbsK30jihz/yJuhULdvayk0WkpQv5GSm7Q408zKlkO0b+yblazpg== 67 | type: consensus 68 | addresses: 69 | - "{{ hostvars['any-sync-consensusnode1'].ansible_host }}:{{ any_sync_consensusnode_yamux_port }}" 70 | - "quic://{{ hostvars['any-sync-consensusnode1'].ansible_host }}:{{ any_sync_consensusnode_quic_port }}" 71 | -------------------------------------------------------------------------------- /inventory.ini: -------------------------------------------------------------------------------- 1 | [all:children] 2 | any_sync 3 | 4 | [any_sync_node] 5 | any-sync-node1 ansible_host=10.10.0.1 6 | any-sync-node2 ansible_host=10.10.0.2 7 | any-sync-node3 ansible_host=10.10.0.3 8 | 9 | [any_sync_filenode] 10 | any-sync-filenode1 ansible_host=10.10.1.1 11 | 12 | [any_sync_coordinator] 13 | any-sync-coordinator1 ansible_host=10.10.2.1 14 | 15 | [any_sync_consensusnode] 16 | any-sync-consensusnode1 ansible_host=10.10.3.1 17 | 18 | [any_sync:children] 19 | any_sync_node 20 | any_sync_filenode 21 | any_sync_coordinator 22 | any_sync_consensusnode 23 | 24 | [mongo] 25 | mongo1 ansible_host=10.10.4.1 26 | mongo2 ansible_host=10.10.4.2 27 | mongo3 ansible_host=10.10.4.3 28 | 29 | [redis] 30 | redis1 ansible_host=10.10.5.1 31 | 32 | ; if you are using a self-hosted s3 storage for example minio 33 | [s3] 34 | minio ansible_host=10.10.6.1 35 | -------------------------------------------------------------------------------- /meta/runtime.yml: -------------------------------------------------------------------------------- 1 | --- 2 | requires_ansible: ">=2.11" 3 | ... 4 | -------------------------------------------------------------------------------- /roles/any_sync_consensusnode/README.md: -------------------------------------------------------------------------------- 1 | Role for deploying an [any-sync-consensusnode](https://github.com/anyproto/any-sync-consensusnode). 2 | -------------------------------------------------------------------------------- /roles/any_sync_consensusnode/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # user and group that the any_sync_consensusnode service will run as 3 | any_sync_consensusnode_user: any-sync-consensusnode 4 | any_sync_consensusnode_group: any-sync-consensusnode 5 | 6 | any_sync_consensusnode_version: 0.2.0 7 | any_sync_consensusnode_release_system: amd64 # aarch64.rpm x86_64.rpm amd64.deb arm64.deb 8 | any_sync_consensusnode_release_name_rhel: "any-sync-consensusnode-{{ any_sync_consensusnode_version }}-1.{{ any_sync_consensusnode_release_system }}.rpm" 9 | any_sync_consensusnode_download_url_rhel: "https://github.com/anyproto/any-sync-consensusnode/releases/download/v{{ any_sync_consensusnode_version}}/{{ any_sync_consensusnode_release_name_rhel }}" 10 | 11 | any_sync_consensusnode_release_name_debian: "any-sync-consensusnode_{{ any_sync_consensusnode_version }}_{{ any_sync_consensusnode_release_system }}.deb" 12 | any_sync_consensusnode_download_url_debian: "https://github.com/anyproto/any-sync-consensusnode/releases/download/v{{ any_sync_consensusnode_version}}/{{ any_sync_consensusnode_release_name_debian }}" 13 | 14 | # any sync consensusnode configuration 15 | # see: https://github.com/anyproto/any-sync-consensusnode/blob/main/etc/any-sync-consensusnode.yml 16 | any_sync_consensusnode_config_path: /etc/any-sync-consensusnode 17 | any_sync_consensusnode_networkStorePath: /var/lib/any-sync-consensusnode/networkStore 18 | 19 | any_sync_consensusnode_metric_port: 8004 20 | any_sync_consensusnode_mongo_url: "mongodb://{{ hostvars['mongo1'].ansible_host }}:27001,{{ hostvars['mongo2'].ansible_host }}:27002,{{ hostvars['mongo3'].ansible_host }}:27003/?w=majority" 21 | 22 | any_sync_consensusnode_config: 23 | metric: 24 | addr: "0.0.0.0:{{ any_sync_consensusnode_metric_port }}" 25 | 26 | log: 27 | defaultLevel: '' 28 | namedLevels: {} 29 | production: false 30 | 31 | networkStorePath: "{{ any_sync_consensusnode_networkStorePath }}" 32 | 33 | mongo: 34 | connect: "{{ any_sync_consensusnode_mongo_url }}" 35 | database: consensus 36 | logCollection: log 37 | 38 | drpc: 39 | stream: 40 | maxMsgSizeMb: 256 41 | 42 | yamux: 43 | dialTimeoutSec: 10 44 | listenAddrs: 45 | - "{{ ansible_host }}:{{ any_sync_consensusnode_yamux_port }}" 46 | writeTimeoutSec: 10 47 | 48 | quic: 49 | dialTimeoutSec: 10 50 | listenAddrs: 51 | - "{{ ansible_host }}:{{ any_sync_consensusnode_quic_port }}" 52 | writeTimeoutSec: 10 53 | -------------------------------------------------------------------------------- /roles/any_sync_consensusnode/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Restart any-sync-consensusnode 3 | systemd: 4 | name: any-sync-consensusnode 5 | daemon_reload: yes 6 | state: restarted 7 | -------------------------------------------------------------------------------- /roles/any_sync_consensusnode/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: anyproto 4 | description: Install any-sync-consensusnode from official repository. 5 | license: MIT 6 | company: Anytype, INC 7 | 8 | min_ansible_version: "2.11" 9 | 10 | platforms: 11 | - name: EL 12 | versions: 13 | - 7 14 | - name: Ubuntu 15 | versions: 16 | - jammy 17 | 18 | dependencies: [] 19 | -------------------------------------------------------------------------------- /roles/any_sync_consensusnode/tasks/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Copy config file 4 | template: 5 | src: config.yml.j2 6 | dest: "{{ any_sync_consensusnode_config_path }}/config.yml" 7 | notify: Restart any-sync-consensusnode 8 | 9 | - name: Copy systemd init file 10 | template: 11 | src: service.j2 12 | dest: /etc/systemd/system/any-sync-consensusnode.service 13 | notify: Restart any-sync-consensusnode 14 | -------------------------------------------------------------------------------- /roles/any_sync_consensusnode/tasks/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Ensure group 3 | group: 4 | name: "{{ any_sync_consensusnode_group }}" 5 | state: present 6 | 7 | - name: Сreate a user 8 | user: 9 | name: "{{ any_sync_consensusnode_user }}" 10 | group: "{{ any_sync_consensusnode_group }}" 11 | state: present 12 | 13 | - name: Ensure skeleton paths 14 | file: 15 | path: "{{ item }}" 16 | state: directory 17 | mode: 0755 18 | owner: "{{ any_sync_consensusnode_user }}" 19 | group: "{{ any_sync_consensusnode_group }}" 20 | with_items: 21 | - "{{ any_sync_consensusnode_config_path }}" 22 | - "{{ any_sync_consensusnode_networkStorePath }}" 23 | 24 | - name: Remote RPM install with yum 25 | yum: 26 | name: "{{ any_sync_consensusnode_download_url_rhel }}" 27 | when: ansible_os_family == 'RedHat' 28 | 29 | - name: Remote DEB install with apt 30 | apt: 31 | deb: "{{ any_sync_consensusnode_download_url_debian }}" 32 | when: ansible_os_family == 'Debian' 33 | -------------------------------------------------------------------------------- /roles/any_sync_consensusnode/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Install 4 | import_tasks: install.yml 5 | tags: 6 | - install 7 | 8 | - name: Configure 9 | import_tasks: config.yml 10 | tags: 11 | - configure 12 | 13 | - name: Service 14 | import_tasks: service.yml 15 | tags: 16 | - service 17 | -------------------------------------------------------------------------------- /roles/any_sync_consensusnode/tasks/service.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Start any-sync-consensusnode service 3 | systemd: 4 | name: any-sync-consensusnode 5 | enabled: yes 6 | state: started 7 | daemon_reload: yes 8 | -------------------------------------------------------------------------------- /roles/any_sync_consensusnode/templates/config.yml.j2: -------------------------------------------------------------------------------- 1 | #jinja2: lstrip_blocks: "True" 2 | --- 3 | account: 4 | peerId: {{ any_sync_config[inventory_hostname]['peerId'] }} 5 | peerKey: {{ any_sync_config[inventory_hostname]['peerKey'] }} 6 | signingKey: {{ any_sync_config[inventory_hostname]['signingKey'] }} 7 | network: 8 | networkId: {{ any_sync_config['networkId'] }} 9 | nodes: 10 | {% for node_name, node in any_sync_config.items() if node_name.startswith('any-sync-') %} 11 | - peerId: {{ node['peerId'] }} 12 | addresses: 13 | {% for address in node['addresses'] %} 14 | - {{ address }} 15 | {% endfor %} 16 | types: 17 | - {{ node['type'] }} 18 | {% endfor %} 19 | {{ any_sync_consensusnode_config | to_nice_yaml(indent=2) }} 20 | -------------------------------------------------------------------------------- /roles/any_sync_consensusnode/templates/service.j2: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=any-sync-consensusnode 3 | Wants=network-online.target 4 | After=syslog.target network.target remote-fs.target nss-lookup.target 5 | 6 | [Service] 7 | Type=simple 8 | User={{ any_sync_consensusnode_user }} 9 | Group={{ any_sync_consensusnode_group }} 10 | AmbientCapabilities=CAP_NET_BIND_SERVICE 11 | ExecStart=/bin/any-sync-consensusnode -c {{ any_sync_consensusnode_config_path }}/config.yml 12 | Restart=on-failure 13 | RestartSec=5 14 | 15 | [Install] 16 | WantedBy=multi-user.target 17 | -------------------------------------------------------------------------------- /roles/any_sync_coordinator/README.md: -------------------------------------------------------------------------------- 1 | Role for deploying an [any-sync-coordinator](https://github.com/anyproto/any-sync-coordinator). 2 | -------------------------------------------------------------------------------- /roles/any_sync_coordinator/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # user and group that the any_sync_coordinator service will run as 3 | any_sync_coordinator_user: any_sync_coordinator 4 | any_sync_coordinator_group: any_sync_coordinator 5 | 6 | any_sync_coordinator_version: 0.4.1 7 | any_sync_coordinator_release_system: amd64 # aarch64.rpm x86_64.rpm amd64.deb arm64.deb 8 | any_sync_coordinator_release_name_rhel: "any-sync-coordinator-{{ any_sync_coordinator_version }}-1.{{ any_sync_coordinator_release_system }}.rpm" 9 | any_sync_coordinator_download_url_rhel: "https://github.com/anyproto/any-sync-coordinator/releases/download/v{{ any_sync_coordinator_version}}/{{ any_sync_coordinator_release_name_rhel }}" 10 | 11 | any_sync_coordinator_release_name_debian: "any-sync-coordinator_{{ any_sync_coordinator_version }}_{{ any_sync_coordinator_release_system }}.deb" 12 | any_sync_coordinator_download_url_debian: "https://github.com/anyproto/any-sync-coordinator/releases/download/v{{ any_sync_coordinator_version}}/{{ any_sync_coordinator_release_name_debian }}" 13 | 14 | # any sync coordinator configuration 15 | # see: https://github.com/anyproto/any-sync-coordinator/blob/main/etc/any-sync-coordinator.yml 16 | any_sync_coordinator_config_path: /etc/any-sync-coordinator 17 | any_sync_coordinator_networkStorePath: /var/lib/any-sync-coordinator/networkStore 18 | 19 | any_sync_coordinator_metric_port: 8002 20 | any_sync_coordinator_mongo_url: "mongodb://{{ hostvars['mongo1'].ansible_host }}:27001,{{ hostvars['mongo2'].ansible_host }}:27002,{{ hostvars['mongo3'].ansible_host }}:27003" 21 | 22 | any_sync_coordinator_config: 23 | drpc: 24 | stream: 25 | maxMsgSizeMb: 256 26 | 27 | defaultLimits: 28 | spaceMembersRead: 1000 29 | spaceMembersWrite: 1000 30 | sharedSpacesLimit: 1000 31 | 32 | log: 33 | defaultLevel: '' 34 | namedLevels: {} 35 | production: false 36 | 37 | networkStorePath: "{{ any_sync_coordinator_networkStorePath }}" 38 | 39 | metric: 40 | addr: "0.0.0.0:{{ any_sync_coordinator_metric_port }}" 41 | 42 | mongo: 43 | connect: "{{ any_sync_coordinator_mongo_url }}" 44 | database: coordinator 45 | log: log 46 | spaces: spaces 47 | 48 | spaceStatus: 49 | runSeconds: 5 50 | deletionPeriodDays: 0 51 | 52 | yamux: 53 | dialTimeoutSec: 10 54 | listenAddrs: 55 | - "{{ ansible_host }}:{{ any_sync_coordinator_yamux_port }}" 56 | writeTimeoutSec: 10 57 | 58 | quic: 59 | dialTimeoutSec: 10 60 | listenAddrs: 61 | - "{{ ansible_host }}:{{ any_sync_coordinator_quic_port }}" 62 | writeTimeoutSec: 10 63 | -------------------------------------------------------------------------------- /roles/any_sync_coordinator/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Restart any-sync-coordinator 3 | systemd: 4 | name: any-sync-coordinator 5 | daemon_reload: yes 6 | state: restarted 7 | -------------------------------------------------------------------------------- /roles/any_sync_coordinator/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: anyproto 4 | description: Install any-sync-coordinator from official repository. 5 | license: MIT 6 | company: Anytype, INC 7 | 8 | min_ansible_version: "2.11" 9 | 10 | platforms: 11 | - name: EL 12 | versions: 13 | - 7 14 | - name: Ubuntu 15 | versions: 16 | - jammy 17 | 18 | dependencies: [] 19 | -------------------------------------------------------------------------------- /roles/any_sync_coordinator/tasks/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Copy config file 4 | template: 5 | src: config.yml.j2 6 | dest: "{{ any_sync_coordinator_config_path }}/config.yml" 7 | notify: Restart any-sync-coordinator 8 | 9 | - name: Copy network config file 10 | template: 11 | src: network.yml.j2 12 | dest: "{{ any_sync_coordinator_config_path }}/network.yml" 13 | 14 | - name: Copy systemd init file 15 | template: 16 | src: service.j2 17 | dest: /etc/systemd/system/any-sync-coordinator.service 18 | notify: Restart any-sync-coordinator 19 | 20 | - name: Apply network configuration 21 | run_once: true 22 | shell: | 23 | sleep 10 24 | any-sync-confapply -c {{ any_sync_coordinator_config_path }}/config.yml -n {{ any_sync_coordinator_config_path }}/network.yml -e 25 | -------------------------------------------------------------------------------- /roles/any_sync_coordinator/tasks/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Ensure group 3 | group: 4 | name: "{{ any_sync_coordinator_group }}" 5 | state: present 6 | 7 | - name: Сreate a user 8 | user: 9 | name: "{{ any_sync_coordinator_user }}" 10 | group: "{{ any_sync_coordinator_group }}" 11 | state: present 12 | 13 | - name: Ensure config path 14 | file: 15 | path: "{{ item }}" 16 | state: directory 17 | mode: 0755 18 | owner: "{{ any_sync_coordinator_user }}" 19 | group: "{{ any_sync_coordinator_group }}" 20 | with_items: 21 | - "{{ any_sync_coordinator_config_path }}" 22 | - "{{ any_sync_coordinator_networkStorePath }}" 23 | 24 | - name: Remote RPM install with yum 25 | yum: 26 | name: "{{ any_sync_coordinator_download_url_rhel }}" 27 | when: ansible_os_family == 'RedHat' 28 | 29 | - name: Remote DEB install with apt 30 | apt: 31 | deb: "{{ any_sync_coordinator_download_url_debian }}" 32 | state: present 33 | when: ansible_os_family == 'Debian' 34 | -------------------------------------------------------------------------------- /roles/any_sync_coordinator/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Install 4 | import_tasks: install.yml 5 | tags: 6 | - install 7 | 8 | - name: Configure 9 | import_tasks: config.yml 10 | tags: 11 | - configure 12 | 13 | - name: Service 14 | import_tasks: service.yml 15 | tags: 16 | - service 17 | -------------------------------------------------------------------------------- /roles/any_sync_coordinator/tasks/service.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Start any-sync-coordinator service 3 | systemd: 4 | name: any-sync-coordinator 5 | enabled: yes 6 | state: started 7 | daemon_reload: yes 8 | -------------------------------------------------------------------------------- /roles/any_sync_coordinator/templates/config.yml.j2: -------------------------------------------------------------------------------- 1 | #jinja2: lstrip_blocks: "True" 2 | --- 3 | account: 4 | peerId: {{ any_sync_config[inventory_hostname]['peerId'] }} 5 | peerKey: {{ any_sync_config[inventory_hostname]['peerKey'] }} 6 | signingKey: {{ any_sync_config[inventory_hostname]['signingKey'] }} 7 | network: 8 | networkId: {{ any_sync_config['networkId'] }} 9 | nodes: 10 | {% for node_name, node in any_sync_config.items() if node_name.startswith('any-sync-') %} 11 | - peerId: {{ node['peerId'] }} 12 | addresses: 13 | {% for address in node['addresses'] %} 14 | - {{ address }} 15 | {% endfor %} 16 | types: 17 | - {{ node['type'] }} 18 | {% endfor %} 19 | {{ any_sync_coordinator_config | to_nice_yaml(indent=2) }} 20 | -------------------------------------------------------------------------------- /roles/any_sync_coordinator/templates/network.yml.j2: -------------------------------------------------------------------------------- 1 | #jinja2: lstrip_blocks: "True" 2 | --- 3 | networkId: {{ any_sync_config['networkId'] }} 4 | nodes: 5 | {% for node_name, node in any_sync_config.items() if node_name.startswith('any-sync-') %} 6 | - peerId: {{ node['peerId'] }} 7 | addresses: 8 | {% for address in node['addresses'] %} 9 | - {{ address }} 10 | {% endfor %} 11 | types: 12 | - {{ node['type'] }} 13 | {% endfor %} 14 | -------------------------------------------------------------------------------- /roles/any_sync_coordinator/templates/service.j2: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=coordinator from any-sync protocol 3 | Wants=network-online.target 4 | After=syslog.target network.target remote-fs.target nss-lookup.target 5 | 6 | [Service] 7 | Type=simple 8 | User={{ any_sync_coordinator_user }} 9 | Group={{ any_sync_coordinator_group }} 10 | AmbientCapabilities=CAP_NET_BIND_SERVICE 11 | ExecStart=/bin/any-sync-coordinator -c {{ any_sync_coordinator_config_path }}/config.yml 12 | Restart=on-failure 13 | RestartSec=5 14 | 15 | [Install] 16 | WantedBy=multi-user.target 17 | -------------------------------------------------------------------------------- /roles/any_sync_filenode/README.md: -------------------------------------------------------------------------------- 1 | Role for deploying an [any-sync-filenode](https://github.com/anyproto/any-sync-filenode). 2 | -------------------------------------------------------------------------------- /roles/any_sync_filenode/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # user and group that the any_sync_filenode service will run as 3 | any_sync_filenode_user: any-sync-filenode 4 | any_sync_filenode_group: any-sync-filenode 5 | 6 | any_sync_filenode_version: 0.8.1 7 | any_sync_filenode_release_system: amd64 # aarch64.rpm x86_64.rpm amd64.deb arm64.deb 8 | any_sync_filenode_release_name_rhel: "any-sync-filenode-{{ any_sync_filenode_version }}-1.{{ any_sync_filenode_release_system }}.rpm" 9 | any_sync_filenode_download_url_rhel: "https://github.com/anyproto/any-sync-filenode/releases/download/v{{ any_sync_filenode_version}}/{{ any_sync_filenode_release_name_rhel }}" 10 | 11 | any_sync_filenode_release_name_debian: "any-sync-filenode_{{ any_sync_filenode_version }}_{{ any_sync_filenode_release_system }}.deb" 12 | any_sync_filenode_download_url_debian: "https://github.com/anyproto/any-sync-filenode/releases/download/v{{ any_sync_filenode_version}}/{{ any_sync_filenode_release_name_debian }}" 13 | 14 | # any sync filenode configuration 15 | # see: https://github.com/anyproto/any-sync-filenode/blob/main/etc/any-sync-filenode.yml 16 | any_sync_filenode_config_path: /etc/any-sync-filenode 17 | any_sync_filenode_networkStorePath: /var/lib/any-sync-filenode/networkStore 18 | 19 | any_sync_filenode_metric_port: 8003 20 | any_sync_filenode_redis_cluster: false 21 | any_sync_filenode_redis_url: "redis://{{ hostvars['redis1'].ansible_host }}:6379?dial_timeout=3&read_timeout=6s" 22 | # any_sync_filenode_redis_cluster: true 23 | # any_sync_filenode_redis_url: "redis://{{ hostvars['redis1'].ansible_host }}:6379?dial_timeout=3&read_timeout=6s&addr={{ hostvars['redis1'].ansible_host }}:6380&addr={{ hostvars['redis2'].ansible_host }}:6379&addr={{ hostvars['redis2'].ansible_host }}:6380&addr={{ hostvars['redis3'].ansible_host }}:6379&addr={{ hostvars['redis3'].ansible_host }}:6380" 24 | 25 | # s3 integration 26 | any_sync_filenode_s3_access: accesskey 27 | any_sync_filenode_s3_secret_access: secretaccesskey 28 | any_sync_filenode_s3_bucket: s3-bucket 29 | 30 | any_sync_filenode_config: 31 | drpc: 32 | stream: 33 | maxMsgSizeMb: 256 34 | 35 | metric: 36 | addr: "0.0.0.0:{{ any_sync_filenode_metric_port }}" 37 | 38 | log: 39 | defaultLevel: '' 40 | namedLevels: {} 41 | production: false 42 | 43 | networkStorePath: "{{ any_sync_filenode_networkStorePath }}" 44 | 45 | redis: 46 | isCluster: "{{ any_sync_filenode_redis_cluster }}" 47 | url: "{{ any_sync_filenode_redis_url }}" 48 | 49 | s3Store: 50 | bucket: "{{ any_sync_filenode_s3_bucket }}" 51 | indexBucket: "{{ any_sync_filenode_s3_bucket }}" 52 | maxThreads: 16 53 | profile: default 54 | region: us-east-1 55 | endpoint: "http://{{ hostvars['minio'].ansible_host }}:9000" # only for self-hosted S3 56 | forcePathStyle: true # only for self-hosted S3 57 | 58 | defaultLimit: 1099511627776 59 | 60 | yamux: 61 | dialTimeoutSec: 10 62 | listenAddrs: 63 | - "{{ ansible_host }}:{{ any_sync_filenode_yamux_port }}" 64 | writeTimeoutSec: 10 65 | 66 | quic: 67 | dialTimeoutSec: 10 68 | listenAddrs: 69 | - "{{ ansible_host }}:{{ any_sync_filenode_quic_port }}" 70 | writeTimeoutSec: 10 71 | -------------------------------------------------------------------------------- /roles/any_sync_filenode/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Restart any-sync-filenode 3 | systemd: 4 | name: any-sync-filenode 5 | daemon_reload: yes 6 | state: restarted 7 | -------------------------------------------------------------------------------- /roles/any_sync_filenode/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: anyproto 4 | description: Install any-sync-filenode from official repository. 5 | license: MIT 6 | company: Anytype, INC 7 | 8 | min_ansible_version: "2.11" 9 | 10 | platforms: 11 | - name: EL 12 | versions: 13 | - 7 14 | - name: Ubuntu 15 | versions: 16 | - jammy 17 | 18 | dependencies: [] 19 | -------------------------------------------------------------------------------- /roles/any_sync_filenode/tasks/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Copy credentials aws_cli 4 | template: 5 | src: aws_credentials.j2 6 | dest: "/home/{{ any_sync_filenode_user }}/.aws/credentials" 7 | mode: 0644 8 | 9 | - name: Copy config file 10 | template: 11 | src: config.yml.j2 12 | dest: "{{ any_sync_filenode_config_path }}/config.yml" 13 | notify: Restart any-sync-filenode 14 | 15 | - name: Copy systemd init file 16 | template: 17 | src: service.j2 18 | dest: /etc/systemd/system/any-sync-filenode.service 19 | notify: Restart any-sync-filenode 20 | -------------------------------------------------------------------------------- /roles/any_sync_filenode/tasks/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Ensure group 3 | group: 4 | name: "{{ any_sync_filenode_group }}" 5 | state: present 6 | 7 | - name: Сreate a user 8 | user: 9 | name: "{{ any_sync_filenode_user }}" 10 | group: "{{ any_sync_filenode_group }}" 11 | state: present 12 | 13 | - name: Ensure config path 14 | file: 15 | path: "{{ item }}" 16 | state: directory 17 | mode: 0755 18 | owner: "{{ any_sync_filenode_user }}" 19 | group: "{{ any_sync_filenode_group }}" 20 | with_items: 21 | - "{{ any_sync_filenode_config_path }}" 22 | - "{{ any_sync_filenode_networkStorePath }}" 23 | - "/home/{{ any_sync_filenode_user }}/.aws" 24 | 25 | - name: Remote RPM install with yum 26 | yum: 27 | name: "{{ any_sync_filenode_download_url_rhel }}" 28 | when: ansible_os_family == 'RedHat' 29 | 30 | - name: Remote DEB install with apt 31 | apt: 32 | deb: "{{ any_sync_filenode_download_url_debian }}" 33 | when: ansible_os_family == 'Debian' 34 | -------------------------------------------------------------------------------- /roles/any_sync_filenode/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Install 4 | import_tasks: install.yml 5 | tags: 6 | - install 7 | 8 | - name: Configure 9 | import_tasks: config.yml 10 | tags: 11 | - configure 12 | 13 | - name: Service 14 | import_tasks: service.yml 15 | tags: 16 | - service 17 | -------------------------------------------------------------------------------- /roles/any_sync_filenode/tasks/service.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Start any-sync-filenode service 3 | systemd: 4 | name: any-sync-filenode 5 | enabled: yes 6 | state: started 7 | daemon_reload: yes 8 | -------------------------------------------------------------------------------- /roles/any_sync_filenode/templates/aws_credentials.j2: -------------------------------------------------------------------------------- 1 | [default] 2 | aws_access_key_id={{ any_sync_filenode_s3_access }} 3 | aws_secret_access_key={{ any_sync_filenode_s3_secret_access }} 4 | -------------------------------------------------------------------------------- /roles/any_sync_filenode/templates/config.yml.j2: -------------------------------------------------------------------------------- 1 | #jinja2: lstrip_blocks: "True" 2 | --- 3 | account: 4 | peerId: {{ any_sync_config[inventory_hostname]['peerId'] }} 5 | peerKey: {{ any_sync_config[inventory_hostname]['peerKey'] }} 6 | signingKey: {{ any_sync_config[inventory_hostname]['signingKey'] }} 7 | network: 8 | networkId: {{ any_sync_config['networkId'] }} 9 | nodes: 10 | {% for node_name, node in any_sync_config.items() if node_name.startswith('any-sync-') %} 11 | - peerId: {{ node['peerId'] }} 12 | addresses: 13 | {% for address in node['addresses'] %} 14 | - {{ address }} 15 | {% endfor %} 16 | types: 17 | - {{ node['type'] }} 18 | {% endfor %} 19 | {{ any_sync_filenode_config | to_nice_yaml(indent=2) }} 20 | -------------------------------------------------------------------------------- /roles/any_sync_filenode/templates/service.j2: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=filenode from any-sync protocol 3 | Wants=network-online.target 4 | After=syslog.target network.target remote-fs.target nss-lookup.target 5 | 6 | [Service] 7 | Type=simple 8 | User={{ any_sync_filenode_user }} 9 | Group={{ any_sync_filenode_group }} 10 | AmbientCapabilities=CAP_NET_BIND_SERVICE 11 | ExecStart=/bin/any-sync-filenode -c {{ any_sync_filenode_config_path }}/config.yml 12 | Restart=on-failure 13 | RestartSec=5 14 | 15 | [Install] 16 | WantedBy=multi-user.target -------------------------------------------------------------------------------- /roles/any_sync_node/README.md: -------------------------------------------------------------------------------- 1 | Role for deploying an [any-sync-node](https://github.com/anyproto/any-sync-node). 2 | -------------------------------------------------------------------------------- /roles/any_sync_node/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # user and group that the any_sync_node service will run as 3 | any_sync_node_user: any-sync-node 4 | any_sync_node_group: any-sync-node 5 | 6 | any_sync_node_version: 0.4.3 7 | any_sync_node_release_system: amd64 # available: aarch64.rpm x86_64.rpm amd64.deb arm64.deb 8 | any_sync_node_release_name_rhel: "any-sync-node-{{ any_sync_node_version }}-1.{{ any_sync_node_release_system }}.rpm" 9 | any_sync_node_download_url_rhel: "https://github.com/anyproto/any-sync-node/releases/download/v{{ any_sync_node_version}}/{{ any_sync_node_release_name_rhel }}" 10 | 11 | any_sync_node_release_name_debian: "any-sync-node_{{ any_sync_node_version }}_{{ any_sync_node_release_system }}.deb" 12 | any_sync_node_download_url_debian: "https://github.com/anyproto/any-sync-node/releases/download/v{{ any_sync_node_version}}/{{ any_sync_node_release_name_debian }}" 13 | 14 | # any sync node configuration 15 | # see: https://github.com/anyproto/any-sync-node/blob/main/etc/any-sync-node.yml 16 | any_sync_node_config_path: /etc/any-sync-node 17 | any_sync_node_networkStorePath: /var/lib/any-sync-node/networkStore 18 | any_sync_node_storage_path: /var/lib/any-sync-node/storage 19 | 20 | any_sync_node_metric_port: 8001 21 | any_sync_node_api_port: 8080 22 | 23 | any_sync_node_config: 24 | apiServer: 25 | listenAddrs: "{{ ansible_host }}:{{ any_sync_node_api_port }}" 26 | 27 | drpc: 28 | stream: 29 | maxMsgSizeMb: 256 30 | timeoutMilliseconds: 1000 31 | 32 | log: 33 | defaultLevel: '' 34 | namedLevels: {} 35 | production: false 36 | 37 | metric: 38 | addr: "0.0.0.0:{{ any_sync_node_metric_port }}" 39 | 40 | nodeSync: 41 | periodicSyncHours: 2 42 | syncOnStart: true 43 | 44 | space: 45 | gcTTL: 60 46 | syncPeriod: 600 47 | 48 | storage: 49 | path: "{{ any_sync_node_storage_path }}" 50 | 51 | networkStorePath: "{{ any_sync_node_networkStorePath }}" 52 | 53 | yamux: 54 | dialTimeoutSec: 10 55 | listenAddrs: 56 | - "{{ ansible_host }}:{{ any_sync_node_yamux_port }}" 57 | writeTimeoutSec: 10 58 | 59 | quic: 60 | dialTimeoutSec: 10 61 | listenAddrs: 62 | - "{{ ansible_host }}:{{ any_sync_node_quic_port }}" 63 | writeTimeoutSec: 10 64 | -------------------------------------------------------------------------------- /roles/any_sync_node/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Restart any-sync-node 3 | systemd: 4 | name: any-sync-node 5 | daemon_reload: yes 6 | state: restarted 7 | -------------------------------------------------------------------------------- /roles/any_sync_node/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: anyproto 4 | description: Install any-sync-node from official repository. 5 | license: MIT 6 | company: Anytype, INC 7 | 8 | min_ansible_version: "2.11" 9 | 10 | platforms: 11 | - name: EL 12 | versions: 13 | - 7 14 | - name: Ubuntu 15 | versions: 16 | - jammy 17 | 18 | dependencies: [] 19 | -------------------------------------------------------------------------------- /roles/any_sync_node/tasks/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Copy config file 4 | template: 5 | src: config.yml.j2 6 | dest: "{{ any_sync_node_config_path }}/config.yml" 7 | notify: Restart any-sync-node 8 | 9 | - name: Copy systemd init file 10 | template: 11 | src: service.j2 12 | dest: /etc/systemd/system/any-sync-node.service 13 | notify: Restart any-sync-node 14 | -------------------------------------------------------------------------------- /roles/any_sync_node/tasks/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Ensure group 3 | group: 4 | name: "{{ any_sync_node_group }}" 5 | state: present 6 | 7 | - name: Сreate a user 8 | user: 9 | name: "{{ any_sync_node_user }}" 10 | group: "{{ any_sync_node_group }}" 11 | state: present 12 | 13 | - name: Ensure config and storage path 14 | file: 15 | path: "{{ item }}" 16 | state: directory 17 | mode: 0755 18 | owner: "{{ any_sync_node_user }}" 19 | group: "{{ any_sync_node_group }}" 20 | with_items: 21 | - "{{ any_sync_node_config_path }}" 22 | - "{{ any_sync_node_networkStorePath }}" 23 | - "{{ any_sync_node_storage_path }}" 24 | 25 | - name: Remote RPM install with yum 26 | yum: 27 | name: "{{ any_sync_node_download_url_rhel }}" 28 | when: ansible_os_family == 'RedHat' 29 | 30 | - name: Remote DEB install with apt 31 | apt: 32 | deb: "{{ any_sync_node_download_url_debian }}" 33 | when: ansible_os_family == 'Debian' 34 | -------------------------------------------------------------------------------- /roles/any_sync_node/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Install 4 | import_tasks: install.yml 5 | tags: 6 | - install 7 | 8 | - name: Configure 9 | import_tasks: config.yml 10 | tags: 11 | - configure 12 | 13 | - name: Service 14 | import_tasks: service.yml 15 | tags: 16 | - service 17 | -------------------------------------------------------------------------------- /roles/any_sync_node/tasks/service.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Start any-sync-node service 3 | systemd: 4 | name: any-sync-node 5 | enabled: yes 6 | state: started 7 | daemon_reload: yes 8 | -------------------------------------------------------------------------------- /roles/any_sync_node/templates/config.yml.j2: -------------------------------------------------------------------------------- 1 | #jinja2: lstrip_blocks: "True" 2 | --- 3 | account: 4 | peerId: {{ any_sync_config[inventory_hostname]['peerId'] }} 5 | peerKey: {{ any_sync_config[inventory_hostname]['peerKey'] }} 6 | signingKey: {{ any_sync_config[inventory_hostname]['signingKey'] }} 7 | network: 8 | networkId: {{ any_sync_config['networkId'] }} 9 | nodes: 10 | {% for node_name, node in any_sync_config.items() if node_name.startswith('any-sync-') %} 11 | - peerId: {{ node['peerId'] }} 12 | addresses: 13 | {% for address in node['addresses'] %} 14 | - {{ address }} 15 | {% endfor %} 16 | types: 17 | - {{ node['type'] }} 18 | {% endfor %} 19 | {{ any_sync_node_config | to_nice_yaml(indent=2) }} 20 | -------------------------------------------------------------------------------- /roles/any_sync_node/templates/service.j2: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Node from any-sync protocol 3 | Wants=network-online.target 4 | After=syslog.target network.target remote-fs.target nss-lookup.target 5 | 6 | [Service] 7 | Type=simple 8 | User={{ any_sync_node_user }} 9 | Group={{ any_sync_node_group }} 10 | AmbientCapabilities=CAP_NET_BIND_SERVICE 11 | ExecStart=/bin/any-sync-node -c {{ any_sync_node_config_path }}/config.yml 12 | Restart=on-failure 13 | RestartSec=5 14 | 15 | [Install] 16 | WantedBy=multi-user.target --------------------------------------------------------------------------------