-
Notifications
You must be signed in to change notification settings - Fork 32
Convert into ansible role (#9) #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
madoke
wants to merge
20
commits into
hsanjuan:master
Choose a base branch
from
madoke:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
7b7b40b
new directory structure, old files moved/renamed
madoke 6291d68
use ipfs_enable and ipfs_cluster_enable vars to toggle setup of both …
madoke b9c7445
added molecule test
madoke 3521985
removed old tests folder
madoke d535247
molecule tests almost working
madoke cbbb085
adapt readme file
madoke 7635228
fix meta
madoke 2856fb9
fix systemctl template, default variables and add verifications in th…
madoke aeb749f
fix readme
madoke a9aee2b
remove obsolete tests
madoke 7f6c971
Add support for configuring peering nodes
madoke 367cc1e
update license to MIT
madoke 99e3e9d
delete file with wrond name
madoke cc42484
update molecule tests to use ed25519 keys
madoke 5136ea1
change systemd unit back to send notification
madoke 0bf54c4
fix peering nodes template
madoke fea77b4
Allow optionally setting MemoryMax in systemd for ipfs
mig5 16bca44
Allow setting --routing=auto (for example) in systemd file
mig5 81f027c
Fix routing condition in systemd unit file
mig5 a80ad36
Switch to use kubo instead of go-ipfs as of v0.36.0
mig5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ?