From 7b7b40bd7907ae1de5ca4b3bb5dae119969b76ac Mon Sep 17 00:00:00 2001 From: madoke Date: Mon, 28 Jun 2021 23:03:52 +0100 Subject: [PATCH 01/22] new directory structure, old files moved/renamed --- group_vars/README.md => GROUPVARS.md | 0 host_vars/README.md => HOSTVARS.md | 0 group_vars/ipfs.yml => defaults/main.yml | 12 ++++- group_vars/ipfs_cluster.yml | 5 -- {roles/ipfs/handlers => handlers}/main.yml | 8 ++- ipfs-cluster.yml | 3 -- ipfs.yml | 6 --- meta/main..yml | 52 +++++++++++++++++++ roles/ipfs-cluster/handlers/main.yaml | 16 ------ .../tasks => tasks/ipfs-cluster}/main.yml | 8 +-- {roles/ipfs/tasks => tasks/ipfs}/main.yml | 6 +-- tasks/main.yml | 7 +++ .../ipfs-cluster}/etc/init.d/ipfs-cluster | 0 .../etc/systemd/system/ipfs-cluster.service | 0 .../ipfs-cluster}/identity.json | 0 .../ipfs-cluster}/peerstore | 0 .../ipfs-cluster}/service.json | 0 .../ipfs}/etc/init.d/ipfs | 0 .../ipfs}/etc/systemd/system/ipfs.service | 0 .../ipfs}/home/ipfs/ipfs_default_config | 0 inventory.yml => tests/inventory.yml | 0 tests/test.yml | 5 ++ 22 files changed, 89 insertions(+), 39 deletions(-) rename group_vars/README.md => GROUPVARS.md (100%) rename host_vars/README.md => HOSTVARS.md (100%) rename group_vars/ipfs.yml => defaults/main.yml (58%) delete mode 100644 group_vars/ipfs_cluster.yml rename {roles/ipfs/handlers => handlers}/main.yml (80%) delete mode 100644 ipfs-cluster.yml delete mode 100644 ipfs.yml create mode 100644 meta/main..yml delete mode 100644 roles/ipfs-cluster/handlers/main.yaml rename {roles/ipfs-cluster/tasks => tasks/ipfs-cluster}/main.yml (95%) rename {roles/ipfs/tasks => tasks/ipfs}/main.yml (97%) create mode 100644 tasks/main.yml rename {roles/ipfs-cluster/templates => templates/ipfs-cluster}/etc/init.d/ipfs-cluster (100%) rename {roles/ipfs-cluster/templates => templates/ipfs-cluster}/etc/systemd/system/ipfs-cluster.service (100%) rename {roles/ipfs-cluster/templates => templates/ipfs-cluster}/identity.json (100%) rename {roles/ipfs-cluster/templates => templates/ipfs-cluster}/peerstore (100%) rename {roles/ipfs-cluster/templates => templates/ipfs-cluster}/service.json (100%) rename {roles/ipfs/templates => templates/ipfs}/etc/init.d/ipfs (100%) rename {roles/ipfs/templates => templates/ipfs}/etc/systemd/system/ipfs.service (100%) rename {roles/ipfs/templates => templates/ipfs}/home/ipfs/ipfs_default_config (100%) rename inventory.yml => tests/inventory.yml (100%) create mode 100644 tests/test.yml diff --git a/group_vars/README.md b/GROUPVARS.md similarity index 100% rename from group_vars/README.md rename to GROUPVARS.md diff --git a/host_vars/README.md b/HOSTVARS.md similarity index 100% rename from host_vars/README.md rename to HOSTVARS.md diff --git a/group_vars/ipfs.yml b/defaults/main.yml similarity index 58% rename from group_vars/ipfs.yml rename to defaults/main.yml index 2f04eac..d36206e 100644 --- a/group_vars/ipfs.yml +++ b/defaults/main.yml @@ -1,4 +1,7 @@ dist_url: https://dist.ipfs.io + +# IPFS + ipfs_version: v0.4.19 ipfs_arch: amd64 ipfs_home: /home/ipfs @@ -11,4 +14,11 @@ ipfs_discovery: false ipfs_disk_sync: true ipfs_routing: dht ipfs_disable_bandthwidth_metrics: false -ipfs_reprovider_strategy: all \ No newline at end of file +ipfs_reprovider_strategy: all + +# IPFS Cluster + +ipfs_cluster_secret: "use `od -vN 32 -An -tx1 /dev/urandom | tr -d ' \n' ; echo` to generate this" +ipfs_cluster_arch: amd64 +ipfs_cluster_version: v0.10.0 +ipfs_cluster_fd_max: 10000 diff --git a/group_vars/ipfs_cluster.yml b/group_vars/ipfs_cluster.yml deleted file mode 100644 index fbb19e4..0000000 --- a/group_vars/ipfs_cluster.yml +++ /dev/null @@ -1,5 +0,0 @@ -dist_url: https://dist.ipfs.io -ipfs_cluster_secret: "use `od -vN 32 -An -tx1 /dev/urandom | tr -d ' \n' ; echo` to generate this" -ipfs_cluster_arch: amd64 -ipfs_cluster_version: v0.10.0 -ipfs_cluster_fd_max: 10000 diff --git a/roles/ipfs/handlers/main.yml b/handlers/main.yml similarity index 80% rename from roles/ipfs/handlers/main.yml rename to handlers/main.yml index 186859f..0c353fd 100644 --- a/roles/ipfs/handlers/main.yml +++ b/handlers/main.yml @@ -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', '<')) @@ -15,3 +14,10 @@ name: ipfs enabled: yes state: restarted + +- name: restart IPFS Cluster + become: yes + service: + name: ipfs-cluster + enabled: yes + state: restarted diff --git a/ipfs-cluster.yml b/ipfs-cluster.yml deleted file mode 100644 index 057df2c..0000000 --- a/ipfs-cluster.yml +++ /dev/null @@ -1,3 +0,0 @@ -- hosts: ipfs - roles: - - ipfs-cluster diff --git a/ipfs.yml b/ipfs.yml deleted file mode 100644 index 7108d2f..0000000 --- a/ipfs.yml +++ /dev/null @@ -1,6 +0,0 @@ -- hosts: ipfs - roles: - - ipfs -- hosts: ipfs_cluster - roles: - - ipfs-cluster diff --git a/meta/main..yml b/meta/main..yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/meta/main..yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # 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: license (GPL-2.0-or-later, MIT, etc) + + 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. diff --git a/roles/ipfs-cluster/handlers/main.yaml b/roles/ipfs-cluster/handlers/main.yaml deleted file mode 100644 index 8381b32..0000000 --- a/roles/ipfs-cluster/handlers/main.yaml +++ /dev/null @@ -1,16 +0,0 @@ -- name: reload systemd - become: yes - systemd: daemon_reload=yes - notify: restart IPFS Cluster - when: - - not (ansible_distribution == "Amazon" and ansible_distribution_major_version == "NA") - - not (ansible_distribution == "Ubuntu" and ansible_distribution_version is version('15.04', '<')) - - not (ansible_distribution == "Debian" and ansible_distribution_version is version('8', '<')) - - -- name: restart IPFS Cluster - become: yes - service: - name: ipfs-cluster - enabled: yes - state: restarted diff --git a/roles/ipfs-cluster/tasks/main.yml b/tasks/ipfs-cluster/main.yml similarity index 95% rename from roles/ipfs-cluster/tasks/main.yml rename to tasks/ipfs-cluster/main.yml index 012a5cf..96f4af0 100644 --- a/roles/ipfs-cluster/tasks/main.yml +++ b/tasks/ipfs-cluster/main.yml @@ -45,7 +45,7 @@ - name: install ipfs-cluster init service become: yes template: - src: etc/systemd/system/ipfs-cluster.service + src: ipfs-cluster/etc/systemd/system/ipfs-cluster.service dest: /etc/systemd/system/ipfs-cluster.service owner: root group: root @@ -61,7 +61,7 @@ - name: install ipfs-custer init service become: yes template: - src: etc/init.d/ipfs-cluster + src: ipfs-cluster/etc/init.d/ipfs-cluster dest: /etc/init.d/ipfs-cluster owner: root group: root @@ -85,7 +85,7 @@ - name: copy configuration become: yes template: - src: "{{ item }}" + src: "ipfs-cluster/{{ item }}" dest: "{{ ipfs_home }}/.ipfs-cluster/{{ item }}" mode: 0600 owner: ipfs @@ -110,7 +110,7 @@ - name: copy peerstore become: yes template: - src: peerstore + src: ipfs-cluster/peerstore dest: "{{ ipfs_home }}/.ipfs-cluster/peerstore" mode: 0600 owner: ipfs diff --git a/roles/ipfs/tasks/main.yml b/tasks/ipfs/main.yml similarity index 97% rename from roles/ipfs/tasks/main.yml rename to tasks/ipfs/main.yml index 9f6077c..789eeab 100644 --- a/roles/ipfs/tasks/main.yml +++ b/tasks/ipfs/main.yml @@ -37,7 +37,7 @@ - name: install ipfs systemd init service become: yes template: - src: etc/systemd/system/ipfs.service + src: ipfs/etc/systemd/system/ipfs.service dest: /etc/systemd/system/ipfs.service owner: root group: root @@ -55,7 +55,7 @@ - name: install ipfs init service become: yes template: - src: etc/init.d/ipfs + src: ipfs/etc/init.d/ipfs dest: /etc/init.d/ipfs owner: root group: root @@ -90,7 +90,7 @@ - name: copy default config become: yes template: - src: home/ipfs/ipfs_default_config + src: ipfs/home/ipfs/ipfs_default_config dest: "{{ ipfs_home }}/ipfs_default_config" owner: ipfs group: ipfs diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..0dfd0e8 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,7 @@ +- name: Set up ipfs + include_tasks: "{{ role_path }}/tasks/ipfs/main.yml" + tags: ipfs + +- name: Set up ipfs-cluster + include_tasks: "{{ role_path }}/tasks/ipfs-cluster/main.yml" + tags: ipfs \ No newline at end of file diff --git a/roles/ipfs-cluster/templates/etc/init.d/ipfs-cluster b/templates/ipfs-cluster/etc/init.d/ipfs-cluster similarity index 100% rename from roles/ipfs-cluster/templates/etc/init.d/ipfs-cluster rename to templates/ipfs-cluster/etc/init.d/ipfs-cluster diff --git a/roles/ipfs-cluster/templates/etc/systemd/system/ipfs-cluster.service b/templates/ipfs-cluster/etc/systemd/system/ipfs-cluster.service similarity index 100% rename from roles/ipfs-cluster/templates/etc/systemd/system/ipfs-cluster.service rename to templates/ipfs-cluster/etc/systemd/system/ipfs-cluster.service diff --git a/roles/ipfs-cluster/templates/identity.json b/templates/ipfs-cluster/identity.json similarity index 100% rename from roles/ipfs-cluster/templates/identity.json rename to templates/ipfs-cluster/identity.json diff --git a/roles/ipfs-cluster/templates/peerstore b/templates/ipfs-cluster/peerstore similarity index 100% rename from roles/ipfs-cluster/templates/peerstore rename to templates/ipfs-cluster/peerstore diff --git a/roles/ipfs-cluster/templates/service.json b/templates/ipfs-cluster/service.json similarity index 100% rename from roles/ipfs-cluster/templates/service.json rename to templates/ipfs-cluster/service.json diff --git a/roles/ipfs/templates/etc/init.d/ipfs b/templates/ipfs/etc/init.d/ipfs similarity index 100% rename from roles/ipfs/templates/etc/init.d/ipfs rename to templates/ipfs/etc/init.d/ipfs diff --git a/roles/ipfs/templates/etc/systemd/system/ipfs.service b/templates/ipfs/etc/systemd/system/ipfs.service similarity index 100% rename from roles/ipfs/templates/etc/systemd/system/ipfs.service rename to templates/ipfs/etc/systemd/system/ipfs.service diff --git a/roles/ipfs/templates/home/ipfs/ipfs_default_config b/templates/ipfs/home/ipfs/ipfs_default_config similarity index 100% rename from roles/ipfs/templates/home/ipfs/ipfs_default_config rename to templates/ipfs/home/ipfs/ipfs_default_config diff --git a/inventory.yml b/tests/inventory.yml similarity index 100% rename from inventory.yml rename to tests/inventory.yml diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..fbe21ff --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: ipfs + remote_user: root + roles: + - ansible-ipfs-cluster \ No newline at end of file From 6291d68a216d2d8138bf96eb4a84490f2f002108 Mon Sep 17 00:00:00 2001 From: madoke Date: Tue, 29 Jun 2021 09:30:21 +0100 Subject: [PATCH 02/22] use ipfs_enable and ipfs_cluster_enable vars to toggle setup of both apps --- defaults/main.yml | 8 ++++++-- tasks/main.yml | 4 +++- vars/main.yml | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 vars/main.yml diff --git a/defaults/main.yml b/defaults/main.yml index d36206e..844db34 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,7 +1,8 @@ -dist_url: https://dist.ipfs.io - # IPFS +# override to disable go-ipfs setup +ipfs_enable: true + ipfs_version: v0.4.19 ipfs_arch: amd64 ipfs_home: /home/ipfs @@ -18,6 +19,9 @@ ipfs_reprovider_strategy: all # IPFS Cluster +# override to disable ipfs cluster setup +ipfs_cluster_enable: true + ipfs_cluster_secret: "use `od -vN 32 -An -tx1 /dev/urandom | tr -d ' \n' ; echo` to generate this" ipfs_cluster_arch: amd64 ipfs_cluster_version: v0.10.0 diff --git a/tasks/main.yml b/tasks/main.yml index 0dfd0e8..d3bb705 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,7 +1,9 @@ - name: Set up ipfs include_tasks: "{{ role_path }}/tasks/ipfs/main.yml" tags: ipfs + when: ipfs_enable | bool - name: Set up ipfs-cluster include_tasks: "{{ role_path }}/tasks/ipfs-cluster/main.yml" - tags: ipfs \ No newline at end of file + tags: ipfs-cluster + when: ipfs_cluster_enable | bool \ No newline at end of file diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..50c7b10 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1 @@ +dist_url: https://dist.ipfs.io From b9c74452e21e16b8dc21175e3c66f8cb18027cc6 Mon Sep 17 00:00:00 2001 From: madoke Date: Wed, 30 Jun 2021 22:48:53 +0100 Subject: [PATCH 03/22] added molecule test --- molecule/default/converge.yml | 15 +++++++++++++++ molecule/default/molecule.yml | 13 +++++++++++++ molecule/default/verify.yml | 10 ++++++++++ 3 files changed, 38 insertions(+) create mode 100644 molecule/default/converge.yml create mode 100644 molecule/default/molecule.yml create mode 100644 molecule/default/verify.yml diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml new file mode 100644 index 0000000..dacb6f8 --- /dev/null +++ b/molecule/default/converge.yml @@ -0,0 +1,15 @@ +--- +- name: Converge + hosts: all + tasks: + - name: "Include ansible-ipfs-cluster" + vars: + ipfs_enable: true + ipfs_peer_id: "123" + ipfs_private_key: "private-key-123" + ipfs_cluster_enable: true + ipfs_cluster_id: "456" + ipfs_cluster_private_key: "cluster-private-key-456" + ipfs_cluster_peer_addr: "cluster-peer-addr" + include_role: + name: "ansible-ipfs-cluster" diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml new file mode 100644 index 0000000..b5710a8 --- /dev/null +++ b/molecule/default/molecule.yml @@ -0,0 +1,13 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: instance + image: docker.io/pycontribs/centos:8 + pre_build_image: true +provisioner: + name: ansible +verifier: + name: ansible diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml new file mode 100644 index 0000000..79044cd --- /dev/null +++ b/molecule/default/verify.yml @@ -0,0 +1,10 @@ +--- +# This is an example playbook to execute Ansible tests. + +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Example assertion + assert: + that: true From 3521985456c4967ebd991b645f3b1ec001c50bf1 Mon Sep 17 00:00:00 2001 From: madoke Date: Wed, 30 Jun 2021 22:49:53 +0100 Subject: [PATCH 04/22] removed old tests folder --- tests/inventory.yml | 5 ----- tests/test.yml | 5 ----- 2 files changed, 10 deletions(-) delete mode 100644 tests/inventory.yml delete mode 100644 tests/test.yml diff --git a/tests/inventory.yml b/tests/inventory.yml deleted file mode 100644 index d19a4a6..0000000 --- a/tests/inventory.yml +++ /dev/null @@ -1,5 +0,0 @@ -[ipfs] -# Write here your ipfs nodes - -[ipfs_cluster:children] -ipfs \ No newline at end of file diff --git a/tests/test.yml b/tests/test.yml deleted file mode 100644 index fbe21ff..0000000 --- a/tests/test.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- hosts: ipfs - remote_user: root - roles: - - ansible-ipfs-cluster \ No newline at end of file From d535247d8f146b9a3e3f9366b9862456b44918b2 Mon Sep 17 00:00:00 2001 From: madoke Date: Thu, 1 Jul 2021 00:27:22 +0100 Subject: [PATCH 05/22] molecule tests almost working --- molecule/default/converge.yml | 7 +------ molecule/default/molecule.yml | 19 ++++++++++++++++--- tasks/ipfs/main.yml | 20 +------------------- tasks/main.yml | 17 +++++++++++++++++ 4 files changed, 35 insertions(+), 28 deletions(-) diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index dacb6f8..4b0cb04 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -4,12 +4,7 @@ tasks: - name: "Include ansible-ipfs-cluster" vars: - ipfs_enable: true - ipfs_peer_id: "123" - ipfs_private_key: "private-key-123" + ipfs_enable: false ipfs_cluster_enable: true - ipfs_cluster_id: "456" - ipfs_cluster_private_key: "cluster-private-key-456" - ipfs_cluster_peer_addr: "cluster-peer-addr" include_role: name: "ansible-ipfs-cluster" diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index b5710a8..99ef418 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -4,10 +4,23 @@ dependency: driver: name: docker platforms: - - name: instance - image: docker.io/pycontribs/centos:8 - pre_build_image: true + - name: instance-1 + image: centos:8 + command: /sbin/init + privileged: True + groups: + - ipfs_cluster provisioner: name: ansible + inventory: + host_vars: + instance-1: + ipfs_peer_id: "QmUdZCogpVVrPMxdPHhtT2KuUuxNVi1uLb7UC4HwHBqejb" + ipfs_private_key: "CAASqAkwggSkAgEAAoIBAQC3NFhK6XMF9tDDky2aoCdwnNsIzk0DnvkVtfTsM1/fCqnrlMDzvVOY7tsMFBNBHsjCAuLwjUMxtLTgY2+8b8vil5TTuYk0A2nCCTwyxqKHoxwn5RW3J5HlBBMgTV9vKtRyrDONFnRwvVmUbCaxblOp74tl03KEfF3zH46+vz8bzVeNdqDrGmEIc1tWnERddFAeqcM5r8fhNVsVInCWFThqFA2qUahif43Uo1B/gBySnyXWr61htiHoWBXqPK8eFk4FCBodhs+Ct81KE4QQhV9OQaZeQkChGezIPidvwiojY8Lr40xBsRn0H95AKYWwdo0lTbAJ7dt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w/9arJrEZbE1BHhKxDgWOIlGW4xtFC+83kaAim0H/TnQtlwC3ewRi6eM+/zyKERixmQdO/qyEU5Vo3lrU2oRdEeSrhPDZRpXYFzd80CgYEAyV3hgwo2wMkGyYsdGFtzohLwz4kQuv6ntopULyFXHDVMxFOxNWYZuC+y2dn8f1qKjRsUrPNLa6jOaGem6xNKzc1iWokfEk30xKkN2lZcnxZYdjzsHtquoZs7tnlXCwyDbIOmmD+cG2FBQ8hINVzo0HaUtlchkDv3qKaGYFGmg0cCgYEAweI10nMYbtBJAMZGwkONNzf44Re4aTOCES2884oN/zZleKM4H6dMnNyvRKskI8Y3xa0a0sqhDi1n0GE57Qh6BMssMulKwsd15jTm80gcxXC9EWWu26kgGm7IHbb9ZYy6RJ77YFUOcmkF56bLA7mBldEEUCzccqrsOQVaTPV4qIECgYBRktOJVzjpDkbOnKlztZB5ZrzhBgCeEA12+EC0Owhj5/+qRNEz9aGTqNcGQ7VzDgW0tfTBP2odOewsBVlsP4t9JaejT4sjyirPBEEVYwjwdYfuli19Lk+yLgWZnTwywKX47rgtUw91VAexYtBFtdampHMIDvIM0Q455wPmvwz6fwKBgQCoPJBvL5jvA94a29NXMNtNYsxH12wOxwO9fFkY4PjnO+U/Qb4vI1PZoUzpMx63xmW0VfUEALyRQqwbV3mUmQtSNRFhw1Hxtlbv2gA/mOs7eINGf4X5cVctp0MWlpBzDFEZI7Z7tpc893Cuu4F28MS3VgGhyc/zHOymHDNuvm+QGw==" + ipfs_cluster_peer_addr: "/dns4/node01/tcp/9096/ipfs/QmUdZCogpVVrPMxdPHhtT2KuUuxNVi1uLb7UC4HwHBqejb" verifier: name: ansible diff --git a/tasks/ipfs/main.yml b/tasks/ipfs/main.yml index 789eeab..4fae0a0 100644 --- a/tasks/ipfs/main.yml +++ b/tasks/ipfs/main.yml @@ -69,24 +69,6 @@ tags: - init - -- name: make ipfs group - become: yes - group: - state: present - name: ipfs - -- name: make ipfs user - become: yes - user: - state: present - name: ipfs - group: ipfs - shell: /bin/bash - home: "{{ ipfs_home }}" - comment: IPFS user - system: yes - - name: copy default config become: yes template: @@ -101,7 +83,7 @@ - name: init IPFS become: yes become_user: ipfs - command: ipfs init --empty-repo -- {{ ipfs_home }}/ipfs_default_config + command: /usr/local/bin/ipfs init --empty-repo -- {{ ipfs_home }}/ipfs_default_config args: creates: "{{ ipfs_home }}/.ipfs/config" notify: restart IPFS diff --git a/tasks/main.yml b/tasks/main.yml index d3bb705..edddcd9 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,3 +1,20 @@ +- name: make ipfs group + become: yes + group: + state: present + name: ipfs + +- name: make ipfs user + become: yes + user: + state: present + name: ipfs + group: ipfs + shell: /bin/bash + home: "{{ ipfs_home }}" + comment: IPFS user + system: yes + - name: Set up ipfs include_tasks: "{{ role_path }}/tasks/ipfs/main.yml" tags: ipfs From cbbb0854063531480106736faee2b585d30cffbe Mon Sep 17 00:00:00 2001 From: madoke Date: Fri, 2 Jul 2021 21:35:36 +0100 Subject: [PATCH 06/22] adapt readme file --- GROUPVARS.md | 10 --- HOSTVARS.md | 65 ------------------- Makefile | 6 -- README.md | 117 +++++++++++++++++++++++++++------- molecule/default/converge.yml | 2 +- molecule/default/molecule.yml | 2 - 6 files changed, 96 insertions(+), 106 deletions(-) delete mode 100644 GROUPVARS.md delete mode 100644 HOSTVARS.md delete mode 100644 Makefile diff --git a/GROUPVARS.md b/GROUPVARS.md deleted file mode 100644 index a834161..0000000 --- a/GROUPVARS.md +++ /dev/null @@ -1,10 +0,0 @@ -# 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. - -Edit the `ipfs.yml` file 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. diff --git a/HOSTVARS.md b/HOSTVARS.md deleted file mode 100644 index 115890f..0000000 --- a/HOSTVARS.md +++ /dev/null @@ -1,65 +0,0 @@ -# Setting up `host_vars` for each IPFS Cluster node - -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_private_key: "" - -ipfs_cluster_id: "" -ipfs_cluster_private_key: "" - -ipfs_cluster_peer_addr: "/dns4//tcp/9096/ipfs/" -``` - -To generate the `ipfs_peer_id`/`ipfs_private_key` and -`ipfs_cluster_id`/`ipfs_cluster_private_key` key-pairs, use [`ipfs-key`]. They -must 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: ` 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//tcp/9096/ipfs/" -``` -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/ diff --git a/Makefile b/Makefile deleted file mode 100644 index 197e8f4..0000000 --- a/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -all: ipfs ipfs-cluster -ipfs: - ansible-playbook -i inventory.yml ipfs.yml -ipfs-cluster: - ansible-playbook -i inventory.yml ipfs-cluster.yml -.PHONY = all ipfs ipfs-cluster diff --git a/README.md b/README.md index 4c92038..ca92313 100644 --- a/README.md +++ b/README.md @@ -6,30 +6,103 @@ This repository contains Ansible roles to install and run 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. +- Edit the `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` +- 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 `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. + +### 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_private_key: "" + +ipfs_cluster_id: "" +ipfs_cluster_private_key: "" + +ipfs_cluster_peer_addr: "/dns4//tcp/9096/ipfs/" +``` + +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: ` 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//tcp/9096/ipfs/" +``` +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. + +Edit the `ipfs.yml` file 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`. + +```console +python 3 -m molecule test +``` \ No newline at end of file diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 4b0cb04..076172b 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -4,7 +4,7 @@ tasks: - name: "Include ansible-ipfs-cluster" vars: - ipfs_enable: false + ipfs_enable: true ipfs_cluster_enable: true include_role: name: "ansible-ipfs-cluster" diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 99ef418..9808d75 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -18,8 +18,6 @@ provisioner: ipfs_peer_id: "QmUdZCogpVVrPMxdPHhtT2KuUuxNVi1uLb7UC4HwHBqejb" ipfs_private_key: "CAASqAkwggSkAgEAAoIBAQC3NFhK6XMF9tDDky2aoCdwnNsIzk0DnvkVtfTsM1/fCqnrlMDzvVOY7tsMFBNBHsjCAuLwjUMxtLTgY2+8b8vil5TTuYk0A2nCCTwyxqKHoxwn5RW3J5HlBBMgTV9vKtRyrDONFnRwvVmUbCaxblOp74tl03KEfF3zH46+vz8bzVeNdqDrGmEIc1tWnERddFAeqcM5r8fhNVsVInCWFThqFA2qUahif43Uo1B/gBySnyXWr61htiHoWBXqPK8eFk4FCBodhs+Ct81KE4QQhV9OQaZeQkChGezIPidvwiojY8Lr40xBsRn0H95AKYWwdo0lTbAJ7dtFuBinZrTNdSz/AgMBAAECggEAM7Ism+7mCy/LVvSn8LLyjh9k20ZDixsH1G2E0EXq7qg2rIhMLjslZMk5vF3J1R1Xrw9bdF+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zd80CgYEAyV3hgwo2wMkGyYsdGFtzohLwz4kQuv6ntopULyFXHDVMxFOxNWYZuC+y2dn8f1qKjRsUrPNLa6jOaGem6xNKzc1iWokfEk30xKkN2lZcnxZYdjzsHtquoZs7tnlXCwyDbIOmmD+cG2FBQ8hINVzo0HaUtlchkDv3qKaGYFGmg0cCgYEAweI10nMYbtBJAMZGwkONNzf44Re4aTOCES2884oN/zZleKM4H6dMnNyvRKskI8Y3xa0a0sqhDi1n0GE57Qh6BMssMulKwsd15jTm80gcxXC9EWWu26kgGm7IHbb9ZYy6RJ77YFUOcmkF56bLA7mBldEEUCzccqrsOQVaTPV4qIECgYBRktOJVzjpDkbOnKlztZB5ZrzhBgCeEA12+EC0Owhj5/+qRNEz9aGTqNcGQ7VzDgW0tfTBP2odOewsBVlsP4t9JaejT4sjyirPBEEVYwjwdYfuli19Lk+yLgWZnTwywKX47rgtUw91VAexYtBFtdampHMIDvIM0Q455wPmvwz6fwKBgQCoPJBvL5jvA94a29NXMNtNYsxH12wOxwO9fFkY4PjnO+U/Qb4vI1PZoUzpMx63xmW0VfUEALyRQqwbV3mUmQtSNRFhw1Hxtlbv2gA/mOs7eINGf4X5cVctp0MWlpBzDFEZI7Z7tpc893Cuu4F28MS3VgGhyc/zHOymHDNuvm+QGw==" ipfs_cluster_peer_addr: "/dns4/node01/tcp/9096/ipfs/QmUdZCogpVVrPMxdPHhtT2KuUuxNVi1uLb7UC4HwHBqejb" verifier: From 763522814fa6293d6a48a405bbc3f9a25b7cea9a Mon Sep 17 00:00:00 2001 From: madoke Date: Fri, 2 Jul 2021 21:37:20 +0100 Subject: [PATCH 07/22] fix meta --- README.md | 4 ++-- meta/main..yml | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ca92313..40fa9ff 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Ansible roles for `go-ipfs` and `ipfs-cluster` +# Ansible role for `go-ipfs` and `ipfs-cluster` -This repository contains Ansible roles to install and run +This repository contains an Ansible role to install and run [`go-ipfs`](https://github.com/ipfs/go-ipfs) and [`IPFS Cluster`](https://github.com/ipfs/ipfs-cluster). diff --git a/meta/main..yml b/meta/main..yml index c572acc..5702405 100644 --- a/meta/main..yml +++ b/meta/main..yml @@ -1,7 +1,6 @@ galaxy_info: - author: your name - description: your role description - company: your company (optional) + author: Hector Sanjuan + description: Ansible role to install and run go-ipfs and IPFS Cluster # If the issue tracker for your role is not on github, uncomment the # next line and provide a value From 2856fb939605d4fe81afe1aba7e9338c6b7ef6d4 Mon Sep 17 00:00:00 2001 From: madoke Date: Thu, 8 Jul 2021 00:19:44 +0100 Subject: [PATCH 08/22] fix systemctl template, default variables and add verifications in the test --- defaults/main.yml | 6 +-- molecule/default/molecule.yml | 7 +++- molecule/default/verify.yml | 40 ++++++++++++++++--- .../ipfs/etc/systemd/system/ipfs.service | 1 - 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 844db34..fa0d33c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -3,7 +3,7 @@ # override to disable go-ipfs setup ipfs_enable: true -ipfs_version: v0.4.19 +ipfs_version: v0.9.0 ipfs_arch: amd64 ipfs_home: /home/ipfs ipfs_storage_max: 10G @@ -21,8 +21,6 @@ ipfs_reprovider_strategy: all # override to disable ipfs cluster setup ipfs_cluster_enable: true - -ipfs_cluster_secret: "use `od -vN 32 -An -tx1 /dev/urandom | tr -d ' \n' ; echo` to generate this" ipfs_cluster_arch: amd64 -ipfs_cluster_version: v0.10.0 +ipfs_cluster_version: v0.13.3 ipfs_cluster_fd_max: 10000 diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 9808d75..eae2189 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -6,13 +6,18 @@ driver: platforms: - name: instance-1 image: centos:8 - command: /sbin/init + command: "/usr/sbin/init" + volumes: + - "/sys/fs/cgroup:/sys/fs/cgroup:rw" privileged: True groups: - ipfs_cluster provisioner: name: ansible inventory: + group_vars: + ipfs_cluster: + ipfs_cluster_secret: "81643eba8fedcc4aa31fef6459e8b852a97c3cf3d0489158cb85166e8255e912" host_vars: instance-1: ipfs_peer_id: "QmUdZCogpVVrPMxdPHhtT2KuUuxNVi1uLb7UC4HwHBqejb" diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index 79044cd..195e025 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -1,10 +1,40 @@ --- -# This is an example playbook to execute Ansible tests. +# Validates if ipfs and ipfs-cluster are installed and running - name: Verify - hosts: all + hosts: instance-1 gather_facts: false tasks: - - name: Example assertion - assert: - that: true + - name: Check if IPFS is installed + package: + name: ipfs + state: present + check_mode: true + register: install_ipfs + failed_when: (install_ipfs is changed) or (install_ipfs is failed) + + - name: Check if IPFS service is running + service: + name: ipfs + state: started + enabled: true + check_mode: true + register: service_ipfs + failed_when: (service_ipfs is changed) or (service_ipfs is failed) + + - name: Check if IPFS Cluster is installed + package: + name: ipfs-cluster + state: present + check_mode: true + register: install_ipfs_cluster + failed_when: (install_ipfs_cluster is changed) or (install_ipfs_cluster is failed) + + - name: Check if IPFS Cluster service is running + service: + name: ipfs-cluster + state: started + enabled: true + check_mode: true + register: service_ipfs_cluster + failed_when: (service_ipfs_cluster is changed) or (service_ipfs_cluster is failed) \ No newline at end of file diff --git a/templates/ipfs/etc/systemd/system/ipfs.service b/templates/ipfs/etc/systemd/system/ipfs.service index 1e69814..10bb27e 100644 --- a/templates/ipfs/etc/systemd/system/ipfs.service +++ b/templates/ipfs/etc/systemd/system/ipfs.service @@ -3,7 +3,6 @@ Description=IPFS daemon After=network.target [Service] -Type=notify User=ipfs Group=ipfs StateDirectory=ipfs From aeb749f26d2261c95cd1a2715261125bcf41b682 Mon Sep 17 00:00:00 2001 From: madoke Date: Thu, 8 Jul 2021 00:23:43 +0100 Subject: [PATCH 09/22] fix readme --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 40fa9ff..c9bdb15 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,8 @@ If you are familiar with Ansible, you can just re-use the modules in the way that fits you best. Otherwise follow these steps: - Fill in `inventory.yml` and place the hostnames of your nodes under the `[ipfs]` and `[ipfs-cluster]` groups. -- Edit the `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` -- 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). +- 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 `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). @@ -95,13 +95,13 @@ You can also define `ipfs_cluster_peername` to name your cluster peer for convin The `group_vars` file can be used to set variables to control the common configuration for of all ipfs and ipfs-cluster peers. -Edit the `ipfs.yml` file in this folder and set the appropiate values for the variables. +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`. +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 From a9aee2b6651d075a51566c0a93729f0038fe6f5e Mon Sep 17 00:00:00 2001 From: madoke Date: Thu, 8 Jul 2021 00:26:03 +0100 Subject: [PATCH 10/22] remove obsolete tests --- molecule/default/verify.yml | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index 195e025..d38ff8f 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -5,14 +5,7 @@ hosts: instance-1 gather_facts: false tasks: - - name: Check if IPFS is installed - package: - name: ipfs - state: present - check_mode: true - register: install_ipfs - failed_when: (install_ipfs is changed) or (install_ipfs is failed) - + - name: Check if IPFS service is running service: name: ipfs @@ -22,14 +15,6 @@ register: service_ipfs failed_when: (service_ipfs is changed) or (service_ipfs is failed) - - name: Check if IPFS Cluster is installed - package: - name: ipfs-cluster - state: present - check_mode: true - register: install_ipfs_cluster - failed_when: (install_ipfs_cluster is changed) or (install_ipfs_cluster is failed) - - name: Check if IPFS Cluster service is running service: name: ipfs-cluster From 7f6c97167365f40b70cc57b90a213c4c78f31447 Mon Sep 17 00:00:00 2001 From: madoke Date: Sun, 15 Aug 2021 16:58:08 +0100 Subject: [PATCH 11/22] Add support for configuring peering nodes --- templates/ipfs/home/ipfs/ipfs_default_config | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/templates/ipfs/home/ipfs/ipfs_default_config b/templates/ipfs/home/ipfs/ipfs_default_config index 1904570..e0e4682 100644 --- a/templates/ipfs/home/ipfs/ipfs_default_config +++ b/templates/ipfs/home/ipfs/ipfs_default_config @@ -201,7 +201,18 @@ "Router": "" }, "Peering": { + {% if ipfs_peering_nodes is defined and ipfs_peering_nodes|length %} + "Peers":[ + {% for node in ipfs_peering_nodes %} + { + "ID": node.id, + "Addrs": node.addrs + }{% if not loop.last %},{% endif %} + {% endfor %} + ] + {% else %} "Peers": null + {% endif %} }, "DNS": { "Resolvers": {} From 367cc1e460fa6e449caae2f6b07b76f5b617f47a Mon Sep 17 00:00:00 2001 From: madoke Date: Fri, 7 Jan 2022 13:56:56 +0000 Subject: [PATCH 12/22] update license to MIT --- meta/main..yml | 2 +- meta/main.yml | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 meta/main.yml diff --git a/meta/main..yml b/meta/main..yml index 5702405..5d7bac4 100644 --- a/meta/main..yml +++ b/meta/main..yml @@ -13,7 +13,7 @@ galaxy_info: # - GPL-3.0-only # - Apache-2.0 # - CC-BY-4.0 - license: license (GPL-2.0-or-later, MIT, etc) + license: MIT min_ansible_version: 2.1 diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..5d7bac4 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,51 @@ +galaxy_info: + author: Hector Sanjuan + description: Ansible role to install and run go-ipfs 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. From 99e3e9d6b85ade6d7d7c52e4bc25060ab5ef2366 Mon Sep 17 00:00:00 2001 From: madoke Date: Fri, 7 Jan 2022 14:03:51 +0000 Subject: [PATCH 13/22] delete file with wrond name --- meta/main..yml | 51 -------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 meta/main..yml diff --git a/meta/main..yml b/meta/main..yml deleted file mode 100644 index 5d7bac4..0000000 --- a/meta/main..yml +++ /dev/null @@ -1,51 +0,0 @@ -galaxy_info: - author: Hector Sanjuan - description: Ansible role to install and run go-ipfs 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. From cc42484603e7156f59279f8c1c2a102fac0fb724 Mon Sep 17 00:00:00 2001 From: madoke Date: Fri, 7 Jan 2022 14:06:52 +0000 Subject: [PATCH 14/22] update molecule tests to use ed25519 keys --- molecule/default/molecule.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index eae2189..efb6424 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -20,10 +20,10 @@ provisioner: ipfs_cluster_secret: "81643eba8fedcc4aa31fef6459e8b852a97c3cf3d0489158cb85166e8255e912" host_vars: instance-1: - ipfs_peer_id: "QmUdZCogpVVrPMxdPHhtT2KuUuxNVi1uLb7UC4HwHBqejb" - ipfs_private_key: "CAASqAkwggSkAgEAAoIBAQC3NFhK6XMF9tDDky2aoCdwnNsIzk0DnvkVtfTsM1/fCqnrlMDzvVOY7tsMFBNBHsjCAuLwjUMxtLTgY2+8b8vil5TTuYk0A2nCCTwyxqKHoxwn5RW3J5HlBBMgTV9vKtRyrDONFnRwvVmUbCaxblOp74tl03KEfF3zH46+vz8bzVeNdqDrGmEIc1tWnERddFAeqcM5r8fhNVsVInCWFThqFA2qUahif43Uo1B/gBySnyXWr61htiHoWBXqPK8eFk4FCBodhs+Ct81KE4QQhV9OQaZeQkChGezIPidvwiojY8Lr40xBsRn0H95AKYWwdo0lTbAJ7dtFuBinZrTNdSz/AgMBAAECggEAM7Ism+7mCy/LVvSn8LLyjh9k20ZDixsH1G2E0EXq7qg2rIhMLjslZMk5vF3J1R1Xrw9bdF+YL2V7iLnmZLjzQlxdnaUEJ04zQJKUjwtn/3gyULue9hDPZV1R/FJ49IiUbEtVPKGyd8GmjnA6NuUX7KLwpeoVrXbel+U2xXJ332MGU1uydteq4iH27FYKYK+6UZUzHLd+V9BOwzGXEXG22Z25hT8n0mp0u1LcJy5tecAj3PAPW0uhsvAFX95c/jkQRkUNj8mntTb2AL2aw4MGNj8UbLYg0EdBRfE3V+esyj0ob7OUt0Nk5d6yCOBXDSZdD/P1mDYOgiL6JpaG9445YQKBgQDvgSKClI4TmXPerRNHhN8ZKbgLy1Hcu9hMs/pmv4Up0KQ6VbrsArXD1KMglrpsXZojgKeDuLmzLnVmMeslZyYqlWS3wWXeJZ2Ms2PlcnNDQlxlwJbJapNO4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VzDgW0tfTBP2odOewsBVlsP4t9JaejT4sjyirPBEEVYwjwdYfuli19Lk+yLgWZnTwywKX47rgtUw91VAexYtBFtdampHMIDvIM0Q455wPmvwz6fwKBgQCoPJBvL5jvA94a29NXMNtNYsxH12wOxwO9fFkY4PjnO+U/Qb4vI1PZoUzpMx63xmW0VfUEALyRQqwbV3mUmQtSNRFhw1Hxtlbv2gA/mOs7eINGf4X5cVctp0MWlpBzDFEZI7Z7tpc893Cuu4F28MS3VgGhyc/zHOymHDNuvm+QGw==" + ipfs_peer_id: "12D3KooWH31GCY8gjo8n2ucpcqoXzWPWe1jXzLZYKxyBM8WpcVLU" + ipfs_private_key: "CAESQJ0rgc303IwfPtdz6VfR8sHEG13FOrFH3qE8a1jCiz3zaz64d7f/r14AUMxdGtDpan4mlRxpG1XIim8oRydnFKE=" + ipfs_cluster_id: "12D3KooWJg9EybwXzoHV182Zdn7ibftJxZtqS66Boim8fd6ccCw4" + ipfs_cluster_private_key: "CAESQCnWLxgdpNdMwCHOker/ozlR3alTULffh3PIvZECcQCYg53rUlp1Gst4JUNXkPzQrCYH7xNpsrJZKFG7JtzjiJM=" ipfs_cluster_peer_addr: "/dns4/node01/tcp/9096/ipfs/QmUdZCogpVVrPMxdPHhtT2KuUuxNVi1uLb7UC4HwHBqejb" verifier: name: ansible From 5136ea120e2276afc19b1b69ed5e0ea34e732e1d Mon Sep 17 00:00:00 2001 From: madoke Date: Fri, 7 Jan 2022 14:11:31 +0000 Subject: [PATCH 15/22] change systemd unit back to send notification --- templates/ipfs/etc/systemd/system/ipfs.service | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/ipfs/etc/systemd/system/ipfs.service b/templates/ipfs/etc/systemd/system/ipfs.service index 10bb27e..1e69814 100644 --- a/templates/ipfs/etc/systemd/system/ipfs.service +++ b/templates/ipfs/etc/systemd/system/ipfs.service @@ -3,6 +3,7 @@ Description=IPFS daemon After=network.target [Service] +Type=notify User=ipfs Group=ipfs StateDirectory=ipfs From 0bf54c47b1b5f00c27a52f9357a6cf9ed817d49a Mon Sep 17 00:00:00 2001 From: madoke Date: Fri, 7 Jan 2022 14:31:39 +0000 Subject: [PATCH 16/22] fix peering nodes template --- templates/ipfs/home/ipfs/ipfs_default_config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/ipfs/home/ipfs/ipfs_default_config b/templates/ipfs/home/ipfs/ipfs_default_config index e0e4682..8af5185 100644 --- a/templates/ipfs/home/ipfs/ipfs_default_config +++ b/templates/ipfs/home/ipfs/ipfs_default_config @@ -205,8 +205,8 @@ "Peers":[ {% for node in ipfs_peering_nodes %} { - "ID": node.id, - "Addrs": node.addrs + "ID": {{ node.id }}, + "Addrs": {{ node.addrs | to_json }} }{% if not loop.last %},{% endif %} {% endfor %} ] From fea77b44ee72d40c4d5a68350d168806d0b06381 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Wed, 17 Aug 2022 13:48:18 +1000 Subject: [PATCH 17/22] Allow optionally setting MemoryMax in systemd for ipfs --- defaults/main.yml | 5 +++++ templates/ipfs/etc/systemd/system/ipfs.service | 3 +++ 2 files changed, 8 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index fa0d33c..218bdda 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -17,6 +17,11 @@ 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 diff --git a/templates/ipfs/etc/systemd/system/ipfs.service b/templates/ipfs/etc/systemd/system/ipfs.service index 1e69814..69e1f0b 100644 --- a/templates/ipfs/etc/systemd/system/ipfs.service +++ b/templates/ipfs/etc/systemd/system/ipfs.service @@ -9,6 +9,9 @@ Group=ipfs StateDirectory=ipfs TimeoutStartSec=10800 LimitNOFILE={{ ipfs_fd_max }} +{% if ipfs_memory_max is defined %} +MemoryMax={{ ipfs_memory_max }} +{% endif %} MemorySwapMax=0 Environment="IPFS_FD_MAX={{ ipfs_fd_max}}" ExecStart=/usr/local/bin/ipfs daemon --migrate {%- if ipfs_enable_gc | default(False) %} --enable-gc{% endif %} From 16bca445d0101287157b839fc45641a8088ccc42 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Wed, 13 Mar 2024 14:46:11 +1100 Subject: [PATCH 18/22] Allow setting --routing=auto (for example) in systemd file --- templates/ipfs/etc/systemd/system/ipfs.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/ipfs/etc/systemd/system/ipfs.service b/templates/ipfs/etc/systemd/system/ipfs.service index 69e1f0b..9808a16 100644 --- a/templates/ipfs/etc/systemd/system/ipfs.service +++ b/templates/ipfs/etc/systemd/system/ipfs.service @@ -14,7 +14,7 @@ MemoryMax={{ ipfs_memory_max }} {% endif %} MemorySwapMax=0 Environment="IPFS_FD_MAX={{ ipfs_fd_max}}" -ExecStart=/usr/local/bin/ipfs daemon --migrate {%- if ipfs_enable_gc | default(False) %} --enable-gc{% endif %} +ExecStart=/usr/local/bin/ipfs daemon --migrate {%- if ipfs_enable_gc | default(False) %} --enable-gc{% endif %} {%- if ipfs_routing | default(False) %} --routing{% ipfs_routing %} Restart=on-failure KillSignal=SIGINT From 81f027c557aff90c56d236b2e11f34daadffb6b7 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Tue, 11 Jun 2024 13:36:02 +1000 Subject: [PATCH 19/22] Fix routing condition in systemd unit file --- templates/ipfs/etc/systemd/system/ipfs.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/ipfs/etc/systemd/system/ipfs.service b/templates/ipfs/etc/systemd/system/ipfs.service index 9808a16..18c0326 100644 --- a/templates/ipfs/etc/systemd/system/ipfs.service +++ b/templates/ipfs/etc/systemd/system/ipfs.service @@ -14,7 +14,7 @@ MemoryMax={{ ipfs_memory_max }} {% endif %} MemorySwapMax=0 Environment="IPFS_FD_MAX={{ ipfs_fd_max}}" -ExecStart=/usr/local/bin/ipfs daemon --migrate {%- if ipfs_enable_gc | default(False) %} --enable-gc{% endif %} {%- if ipfs_routing | default(False) %} --routing{% ipfs_routing %} +ExecStart=/usr/local/bin/ipfs daemon --migrate {%- if ipfs_enable_gc | default(False) %} --enable-gc{% endif %} {%- if ipfs_routing | default(False) %} --routing={{ ipfs_routing }}{% endif %} Restart=on-failure KillSignal=SIGINT From a80ad36cb0517f0c11dbe0d2fd862284a86231af Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Tue, 15 Jul 2025 08:50:18 +1000 Subject: [PATCH 20/22] Switch to use kubo instead of go-ipfs as of v0.36.0 --- README.md | 8 ++++---- defaults/main.yml | 2 +- meta/main.yml | 2 +- tasks/ipfs/main.yml | 50 ++++++++++----------------------------------- vars/main.yml | 2 +- 5 files changed, 18 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index c9bdb15..c4691b0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# Ansible role for `go-ipfs` and `ipfs-cluster` +# Ansible role for `kubo` and `ipfs-cluster` This repository contains an Ansible role to install and run -[`go-ipfs`](https://github.com/ipfs/go-ipfs) and +[`kubo`](ihttps://github.com/ipfs/kubo) and [`IPFS Cluster`](https://github.com/ipfs/ipfs-cluster). They include a Systemd service file both. @@ -25,7 +25,7 @@ that fits you best. Otherwise follow these steps: - 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 `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). +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. @@ -105,4 +105,4 @@ Assumes you have a working molecule setup with docker, running `molecule test` s ```console python 3 -m molecule test -``` \ No newline at end of file +``` diff --git a/defaults/main.yml b/defaults/main.yml index 218bdda..db69ba4 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,6 @@ # IPFS -# override to disable go-ipfs setup +# override to disable kubo setup ipfs_enable: true ipfs_version: v0.9.0 diff --git a/meta/main.yml b/meta/main.yml index 5d7bac4..5c877ad 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,6 +1,6 @@ galaxy_info: author: Hector Sanjuan - description: Ansible role to install and run go-ipfs and IPFS Cluster + 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 diff --git a/tasks/ipfs/main.yml b/tasks/ipfs/main.yml index 4fae0a0..8bdf949 100644 --- a/tasks/ipfs/main.yml +++ b/tasks/ipfs/main.yml @@ -1,10 +1,10 @@ -- name: create download folder for go-ipfs +- name: create download folder for kubo become: yes file: state: directory owner: root group: root - dest: /opt/go-ipfs/{{ipfs_version}} + dest: /opt/kubo/{{ipfs_version}} - name: download and unpack IPFS when: not ansible_check_mode @@ -12,27 +12,27 @@ - name: download IPFS become: yes get_url: - url: "{{ dist_url }}/go-ipfs/{{ipfs_version}}/go-ipfs_{{ipfs_version}}_linux-{{ipfs_arch}}.tar.gz" - dest: /opt/go-ipfs/{{ipfs_version}}/go-ipfs.tar.gz + url: "{{ dist_url }}/kubo/{{ipfs_version}}/kubo_{{ipfs_version}}_linux-{{ipfs_arch}}.tar.gz" + dest: /opt/kubo/{{ipfs_version}}/kubo.tar.gz timeout: 30 - - name: unpack go-ipfs + - name: unpack kubo become: yes unarchive: remote_src: yes - src: /opt/go-ipfs/{{ipfs_version}}/go-ipfs.tar.gz - dest: /opt/go-ipfs/{{ipfs_version}} - creates: /opt/go-ipfs/{{ipfs_version}}/go-ipfs + src: /opt/kubo/{{ipfs_version}}/kubo.tar.gz + dest: /opt/kubo/{{ipfs_version}} + creates: /opt/kubo/{{ipfs_version}}/kubo notify: restart IPFS - - name: link go-ipfs executable + - name: link kubo executable become: yes file: state: link owner: root group: root dest: /usr/local/bin/ipfs - src: /opt/go-ipfs/{{ipfs_version}}/go-ipfs/ipfs + src: /opt/kubo/{{ipfs_version}}/kubo/ipfs - name: install ipfs systemd init service become: yes @@ -88,34 +88,6 @@ creates: "{{ ipfs_home }}/.ipfs/config" notify: restart IPFS -- name: download and unpack NOpfs - when: not ansible_check_mode - block: - - name: create plugins folder - become: yes - file: - state: directory - owner: ipfs - group: ipfs - dest: "{{ ipfs_home }}/.ipfs/plugins" - - - name: download and unpack nopfs - when: not ansible_check_mode - become: yes - unarchive: - remote_src: yes - src: "https://github.com/ipfs-shipyard/nopfs/releases/download/nopfs-kubo-plugin/{{nopfs_version}}/nopfs-kubo-plugin_{{nopfs_version}}_linux_{{ipfs_arch}}.tar.gz" - dest: "{{ ipfs_home }}/.ipfs/plugins/" - include: - - nopfs-kubo-plugin/nopfs-kubo-plugin - extra_opts: - - "--strip-components=1" - owner: ipfs - group: ipfs - notify: restart IPFS - tags: - - nopfs - - name: set version file (to notify restart on upgrades) become: yes copy: @@ -125,7 +97,7 @@ owner: ipfs group: ipfs notify: restart IPFS - + - name: reload systemd become: yes systemd: diff --git a/vars/main.yml b/vars/main.yml index 50c7b10..3d6e1dc 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1 +1 @@ -dist_url: https://dist.ipfs.io +dist_url: https://dist.ipfs.tech From f8a6acae1fc819cf21db9fe6a1a890eece9e6faa Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Thu, 28 Aug 2025 09:35:32 +1000 Subject: [PATCH 21/22] Add default values for ipfs_connmgr_low_water / ipfs_connmgr_high_water variables. Change GracePeriod to an optional variable too --- templates/ipfs/home/ipfs/ipfs_default_config | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/ipfs/home/ipfs/ipfs_default_config b/templates/ipfs/home/ipfs/ipfs_default_config index 8af5185..c52f6ec 100644 --- a/templates/ipfs/home/ipfs/ipfs_default_config +++ b/templates/ipfs/home/ipfs/ipfs_default_config @@ -187,9 +187,9 @@ }, "ConnMgr": { "Type": "basic", - "LowWater": {{ ipfs_connmgr_low_water }}, - "HighWater": {{ ipfs_connmgr_high_water }}, - "GracePeriod": "30s" + "LowWater": {{ ipfs_connmgr_low_water | default(32) }}, + "HighWater": {{ ipfs_connmgr_high_water | default(96) }}, + "GracePeriod": "{{ ipfs_connmgr_grace_period | default('30s') }}" }, "ResourceMgr": { "MaxMemory": "{{ ipfs_resourcemgr_max_memory | default(0) }}" From fa7f57887b8f963f5b70032f98263bb43babc866 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Wed, 10 Jun 2026 09:24:35 +1000 Subject: [PATCH 22/22] Fix permissions on kubo subfolders. On a system with umask 027, the version-specific kubo folder and its subfolder are not accessible to the 'ipfs' user, and ipfs won't start. Enforce 0755 on these folders. --- tasks/ipfs-cluster/main.yml | 15 ++++++++++++++- tasks/ipfs/main.yml | 12 +++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/tasks/ipfs-cluster/main.yml b/tasks/ipfs-cluster/main.yml index 96f4af0..36a72a6 100644 --- a/tasks/ipfs-cluster/main.yml +++ b/tasks/ipfs-cluster/main.yml @@ -4,6 +4,7 @@ state: directory owner: root group: root + mode: 0755 dest: /opt/ipfs-cluster/{{ipfs_cluster_version}} - name: download and unpack IPFS Cluster @@ -30,6 +31,18 @@ - ipfs-cluster-service - ipfs-cluster-ctl + - name: Ensure permissions are 0755 for the subfolders + become: yes + file: + state: directory + owner: root + group: root + mode: 0755 + dest: /opt/ipfs-cluster/{{ipfs_cluster_version}}/{{ item }} + with_items: + - ipfs-cluster-service + - ipfs-cluster-ctl + - name: link ipfs cluster executables become: yes file: @@ -65,7 +78,7 @@ dest: /etc/init.d/ipfs-cluster owner: root group: root - mode: 0744 + mode: 0755 notify: - restart IPFS Cluster when: diff --git a/tasks/ipfs/main.yml b/tasks/ipfs/main.yml index 8bdf949..deb5568 100644 --- a/tasks/ipfs/main.yml +++ b/tasks/ipfs/main.yml @@ -4,6 +4,7 @@ state: directory owner: root group: root + mode: 0755 dest: /opt/kubo/{{ipfs_version}} - name: download and unpack IPFS @@ -25,6 +26,15 @@ creates: /opt/kubo/{{ipfs_version}}/kubo notify: restart IPFS + - name: Ensure version-specific kubo subfolder is readable by ipfs user + become: yes + file: + state: directory + owner: root + group: root + mode: 0755 + dest: /opt/kubo/{{ipfs_version}}/kubo + - name: link kubo executable become: yes file: @@ -59,7 +69,7 @@ dest: /etc/init.d/ipfs owner: root group: root - mode: 0744 + mode: 0755 notify: - restart IPFS when: