Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7b7b40b
new directory structure, old files moved/renamed
madoke Jun 28, 2021
6291d68
use ipfs_enable and ipfs_cluster_enable vars to toggle setup of both …
madoke Jun 29, 2021
b9c7445
added molecule test
madoke Jun 30, 2021
3521985
removed old tests folder
madoke Jun 30, 2021
d535247
molecule tests almost working
madoke Jun 30, 2021
cbbb085
adapt readme file
madoke Jul 2, 2021
7635228
fix meta
madoke Jul 2, 2021
2856fb9
fix systemctl template, default variables and add verifications in th…
madoke Jul 7, 2021
aeb749f
fix readme
madoke Jul 7, 2021
a9aee2b
remove obsolete tests
madoke Jul 7, 2021
7f6c971
Add support for configuring peering nodes
madoke Aug 15, 2021
367cc1e
update license to MIT
madoke Jan 7, 2022
99e3e9d
delete file with wrond name
madoke Jan 7, 2022
cc42484
update molecule tests to use ed25519 keys
madoke Jan 7, 2022
5136ea1
change systemd unit back to send notification
madoke Jan 7, 2022
0bf54c4
fix peering nodes template
madoke Jan 7, 2022
fea77b4
Allow optionally setting MemoryMax in systemd for ipfs
mig5 Aug 17, 2022
16bca44
Allow setting --routing=auto (for example) in systemd file
mig5 Mar 13, 2024
81f027c
Fix routing condition in systemd unit file
mig5 Jun 11, 2024
a80ad36
Switch to use kubo instead of go-ipfs as of v0.36.0
mig5 Jul 14, 2025
f8a6aca
Add default values for ipfs_connmgr_low_water / ipfs_connmgr_high_wat…
mig5 Aug 27, 2025
4f0ddaf
Merge pull request #5 from madoke/mig5/defaults_for_low_high_water
mig5 Sep 17, 2025
fa7f578
Fix permissions on kubo subfolders.
mig5 Jun 9, 2026
c8f89f9
Merge pull request #6 from madoke/mig/permissions-fix
mig5 Jun 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Makefile

This file was deleted.

123 changes: 98 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,108 @@
# Ansible roles for `go-ipfs` and `ipfs-cluster`
# Ansible role for `kubo` and `ipfs-cluster`

This repository contains Ansible roles to install and run
[`go-ipfs`](https://github.com/ipfs/go-ipfs) and
This repository contains an Ansible role to install and run
[`kubo`](ihttps://github.com/ipfs/kubo) and
[`IPFS Cluster`](https://github.com/ipfs/ipfs-cluster).

They include a Systemd service file both.

## Requirements

- Ansible. you can install it by running `pip install ansible`
- [optional] Working moledule setup with docker for running the tests

## Installation

### Git
Use `git clone` or `git submodule add` to clone the ansible-ipfs-cluster role (`https://github.com/hsanjuan/ansible-ipfs-cluster.git`) into the `roles` folder of your playbook to pull the latest edge commit of the role from GitHub.

## Usage

If you are familiar with Ansible, you can just re-use the modules in the way
that fits you best. Otherwise follow these steps:

0. Make sure you have ansible installed: `pip install ansible`.
1. Fill in `inventory.yml` and place the hostnames of your nodes under the `[ipfs]` group.
2. Edit the `group_vars/ipfs.yml` and `group_vars/ipfs_cluster.yml` file
setting the right configuration values, including generating an
[IPFS Cluster secret](https://cluster.ipfs.io/documentation/guides/security/#the-cluster-secret)
with `od -vN 32 -An -tx1 /dev/urandom | tr -d ' \n' ; echo`
3. Add a file for each hostname (filename is the hostname), to the `host_vars`
folder as outlined in [`host_vars/README.md`](host_vars/README.md),
containing the necessary host-specific variables (example in the
`host_vars` README).
4. Run `make`.

`make` will run ansible for the `ipfs` and the `ipfs-cluster` roles, which
apply to the `[ipfs]` and `[ipfs_cluster]` inventory group. Upon successful,
both `go-ipfs` and `ipfs-cluster` should be running in the nodes (they are
installed under `/usr/local/bin` and run by a created `ipfs` system user).

You can use `systemctl status ipfs` and `systemctl status ipfs-cluster` to
check the status of the new services.

Note that `ipfs` configuration has been generated using `profile=server`, thus
will not automatically scan the local network.
- Fill in `inventory.yml` and place the hostnames of your nodes under the `[ipfs]` and `[ipfs-cluster]` groups.
- Create `group_vars/ipfs.yml` and `group_vars/ipfs_cluster.yml` files setting the right configuration values including generating an [IPFS Cluster secret](https://cluster.ipfs.io/documentation/guides/security/#the-cluster-secret) with `od -vN 32 -An -tx1 /dev/urandom | tr -d ' \n' ; echo`. More details in the [Group Vars](#group-vars) section.
- Add a file for each hostname (filename is the hostname), to the `host_vars` folder as outlined in [Host Vars](#host-vars), containing the necessary host-specific variables (example in the `molecule/default/molecule.yml` file).

Upon successful execution, both `kubo` and `ipfs-cluster` should be running in the nodes (they are installed under `/usr/local/bin` and run by a created `ipfs` system user).

You can use `systemctl status ipfs` and `systemctl status ipfs-cluster` to check the status of the new services.

Note that `ipfs` configuration has been generated using `profile=server`, thus will not automatically scan the local network.

### Host Vars

Add one file for each ipfs-cluster host. The filename should match a domain name from your inventory, i.e. `example.org`.

Each file should contain the following variables, updated for your cluster:

```yaml
ipfs_peer_id: "<ipfs_daemon_peer_id>"
ipfs_private_key: "<ipfs_daemon_private_key>"

ipfs_cluster_id: "<cluster_peer_id>"
ipfs_cluster_private_key: "<cluster_peer_private_key>"

ipfs_cluster_peer_addr: "/dns4/<hostname>/tcp/9096/ipfs/<ipfs_cluster_peer_id>"
```

To generate the `ipfs_peer_id`/`ipfs_private_key` and `ipfs_cluster_id`/`ipfs_cluster_private_key` key-pairs, use [`ipfs-key`]. Theymust be all different (no ID or Key can be shared between daemons).

To install [`ipfs-key`], with Go installed, run:

```console
$ go get github.com/whyrusleeping/ipfs-key
```

then generate a key-pair:

```console
$ ipfs-key | base64 -w 0

# or on macos
$ ipfs-key | base64

Generating a 2048 bit RSA key...
Success!
ID for generated key: Qmat3Bk4SixhZdU5j5pf2uXcpUuTSxKHQu7whbWrdFwn5g
CAASqAkwggSkAgEAAoIBAQCUzxjdml2fORveg9PN98qqiENexLzoaSeNc6N7K8iVzneCU1aDZpM...
```

Where:

- the value of `ID for generated key: <PeerId>` is your `ipfs_peer_id` or `ipfs_cluster_id`
- the subsequent line is your `ipfs_private_key` or `ipfs_cluster_private_key`, encoded as base64

Copy those values into your host config file.

For `ipfs_cluster_peer_addr` you need to specify a valid [multiaddr] by taking the example below

```
"/dns4/<hostname>/tcp/9096/ipfs/<ipfs_cluster_peer_id>"
```
and replacing:

`hostname`: with the host from your invetory that this file is for, e.g `example.org` `ipfs_cluster_peer_id`: with the peer id for this cluster node, that you just created.


You can also define `ipfs_cluster_peername` to name your cluster peer for conviniency. Otherwise, the hostname will be used.

[`ipfs-key`]: https://github.com/whyrusleeping/ipfs-key
[multiaddr]: https://multiformats.io/multiaddr/

### Group Vars

The `group_vars` file can be used to set variables to control the common configuration for of all ipfs and ipfs-cluster peers.

Create `ipfs.yml` and `ipfs-cluster.yml` files in this folder and set the appropiate values for the variables.

Note the cluster `service.json` template can be fully customized by defining the appropiate variables, and otherwise they will take sensisble defaults.

## Running the tests

Assumes you have a working molecule setup with docker, running `molecule test` should spin up a docker container and execute the test playbook declared in `molecule/default/converge.yml` as well as the verifications in `molecule/default/verify.yml`

```console
python 3 -m molecule test
```
31 changes: 31 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# IPFS

# override to disable kubo setup
ipfs_enable: true

ipfs_version: v0.9.0
ipfs_arch: amd64
ipfs_home: /home/ipfs
ipfs_storage_max: 10G
ipfs_bloom_filter_size: 1048576 # 1MB
ipfs_api_listen: /ip4/127.0.0.1/tcp/5001
ipfs_fd_max: 4092
ipfs_use_badger: false
ipfs_discovery: false
ipfs_disk_sync: true
ipfs_routing: dht
ipfs_disable_bandthwidth_metrics: false
ipfs_reprovider_strategy: all

# If you find IPFS uses too much RAM, you can
# limit the max amount in the systemd service
# file by setting this to something suitable:
# ipfs_memory_max: "1.5G"

# IPFS Cluster

# override to disable ipfs cluster setup
ipfs_cluster_enable: true
ipfs_cluster_arch: amd64
ipfs_cluster_version: v0.13.3
ipfs_cluster_fd_max: 10000
10 changes: 0 additions & 10 deletions group_vars/README.md

This file was deleted.

14 changes: 0 additions & 14 deletions group_vars/ipfs.yml

This file was deleted.

5 changes: 0 additions & 5 deletions group_vars/ipfs_cluster.yml

This file was deleted.

8 changes: 7 additions & 1 deletion roles/ipfs/handlers/main.yml → handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
systemd:
daemon_reload: yes
name: ipfs
notify: restart IPFS
when:
- not (ansible_distribution == "Amazon" and ansible_distribution_major_version == "NA")
- not (ansible_distribution == "Ubuntu" and ansible_distribution_version is version('15.04', '<'))
Expand All @@ -15,3 +14,10 @@
name: ipfs
enabled: yes
state: restarted

- name: restart IPFS Cluster

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no reason to restart cluster just because IPFS role has run, is there?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't get this one. the handler is called only if there are tasks with notify: restart IPFS Cluster am I missing something ?

become: yes
service:
name: ipfs-cluster
enabled: yes
state: restarted
65 changes: 0 additions & 65 deletions host_vars/README.md

This file was deleted.

5 changes: 0 additions & 5 deletions inventory.yml

This file was deleted.

3 changes: 0 additions & 3 deletions ipfs-cluster.yml

This file was deleted.

6 changes: 0 additions & 6 deletions ipfs.yml

This file was deleted.

51 changes: 51 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
galaxy_info:
author: Hector Sanjuan
description: Ansible role to install and run kubo and IPFS Cluster

# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker

# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: MIT

min_ansible_version: 2.1

# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:

#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99

galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
10 changes: 10 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Converge
hosts: all
tasks:
- name: "Include ansible-ipfs-cluster"
vars:
ipfs_enable: true
ipfs_cluster_enable: true
include_role:
name: "ansible-ipfs-cluster"
Loading