From 4d6b8dd50d9a182903a7fb5c0f625a1db628fd8e Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sun, 17 Jan 2021 17:44:22 +0100 Subject: [PATCH] updated ipfs state --- states/ipfs/config.sls | 41 +++++++++ states/ipfs/defaults.yaml | 9 ++ states/ipfs/init.sls | 92 +------------------ states/ipfs/install.sls | 34 +++++++ states/ipfs/{ipfs.service => ipfs.service.j2} | 0 states/ipfs/kernelmap.yaml | 12 +++ states/ipfs/map.jinja | 14 +++ states/ipfs/osarchmap.yaml | 21 +++++ states/ipfs/service.sls | 14 +++ 9 files changed, 149 insertions(+), 88 deletions(-) create mode 100644 states/ipfs/config.sls create mode 100644 states/ipfs/defaults.yaml create mode 100644 states/ipfs/install.sls rename states/ipfs/{ipfs.service => ipfs.service.j2} (100%) create mode 100644 states/ipfs/kernelmap.yaml create mode 100644 states/ipfs/map.jinja create mode 100644 states/ipfs/osarchmap.yaml create mode 100644 states/ipfs/service.sls diff --git a/states/ipfs/config.sls b/states/ipfs/config.sls new file mode 100644 index 0000000..070943e --- /dev/null +++ b/states/ipfs/config.sls @@ -0,0 +1,41 @@ +--- +ipfs-set-storagemax: + cmd.run: + - name: /usr/local/sbin/ipfs config Datastore.StorageMax "20GB" + - runas: ipfs + - cwd: /var/lib/ipfs + - watch-in: + - service: ipfs-service + +ipfs-set-headers-1: + cmd.run: + - name: ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]' + - runas: ipfs + - cwd: /var/lib/ipfs + - watch-in: + - service: ipfs-service + +ipfs-set-headers-2: + cmd.run: + #- name: ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://localhost:8888", "http://127.0.0.1:5001", "https://webui.ipfs.io"]' + - name: ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]' + - runas: ipfs + - cwd: /var/lib/ipfs + - watch-in: + - service: ipfs-service + +ipfs-set-api: + cmd.run: + - name: /usr/local/sbin/ipfs config Addresses.API "/ip4/0.0.0.0/tcp/5001" + - runas: ipfs + - cwd: /var/lib/ipfs + - watch-in: + - service: ipfs-service + +ipfs-set-gateway: + cmd.run: + - name: /usr/local/sbin/ipfs config Addresses.Gateway "/ip4/0.0.0.0/tcp/8888" + - runas: ipfs + - cwd: /var/lib/ipfs + - watch-in: + - service: ipfs-service diff --git a/states/ipfs/defaults.yaml b/states/ipfs/defaults.yaml new file mode 100644 index 0000000..38d9413 --- /dev/null +++ b/states/ipfs/defaults.yaml @@ -0,0 +1,9 @@ +--- +ipfs: + enabled: true + install_dir: /usr/local/apps + release_dir: /usr/local/apps/releases + mirror: https://dl.google.com/go/ + version: 1.15.5 + os: linux + arch: amd64 diff --git a/states/ipfs/init.sls b/states/ipfs/init.sls index 60e9991..63261f2 100644 --- a/states/ipfs/init.sls +++ b/states/ipfs/init.sls @@ -1,89 +1,5 @@ --- -ipfs-group: - group.present: - - name: ipfs - - gid: 899 - -ipfs-user: - user.present: - - name: ipfs - - uid: 899 - - gid: 899 - - home: /var/lib/ipfs - - allow_uid_change: true - - allow_gid_change: true - -ipfs-dir: - file.directory: - - name: /var/lib/ipfs - - user: ipfs - - group: ipfs - - mode: 0750 - - recurse: - - user - -ipfs-init: - cmd.run: - - name: /usr/local/sbin/ipfs init - - runas: ipfs - - cwd: /var/lib/ipfs - - success_retcodes: - - 0 - - 1 - - watch-in: - - service: ipfs-service - -ipfs-set-storagemax: - cmd.run: - - name: /usr/local/sbin/ipfs config Datastore.StorageMax "20GB" - - runas: ipfs - - cwd: /var/lib/ipfs - - watch-in: - - service: ipfs-service - -ipfs-set-headers-1: - cmd.run: - - name: ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]' - - runas: ipfs - - cwd: /var/lib/ipfs - - watch-in: - - service: ipfs-service - -ipfs-set-headers-2: - cmd.run: - #- name: ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://localhost:8888", "http://127.0.0.1:5001", "https://webui.ipfs.io"]' - - name: ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]' - - runas: ipfs - - cwd: /var/lib/ipfs - - watch-in: - - service: ipfs-service - -ipfs-set-api: - cmd.run: - - name: /usr/local/sbin/ipfs config Addresses.API "/ip4/0.0.0.0/tcp/5001" - - runas: ipfs - - cwd: /var/lib/ipfs - - watch-in: - - service: ipfs-service - -ipfs-set-gateway: - cmd.run: - - name: /usr/local/sbin/ipfs config Addresses.Gateway "/ip4/0.0.0.0/tcp/8888" - - runas: ipfs - - cwd: /var/lib/ipfs - - watch-in: - - service: ipfs-service - -ipfs-service-file: - file.managed: - - name: /etc/systemd/system/ipfs.service - - source: salt://ipfs/ipfs.service - - watch-in: - - service: ipfs-service - -ipfs-service: - service.running: - - name: ipfs - - enable: true - - require: - - file: ipfs-dir \ No newline at end of file +include: + - .install + - .config + - .service \ No newline at end of file diff --git a/states/ipfs/install.sls b/states/ipfs/install.sls new file mode 100644 index 0000000..2f5ebaa --- /dev/null +++ b/states/ipfs/install.sls @@ -0,0 +1,34 @@ +--- +ipfs-group: + group.present: + - name: ipfs + - gid: 899 + +ipfs-user: + user.present: + - name: ipfs + - uid: 899 + - gid: 899 + - home: /var/lib/ipfs + - allow_uid_change: true + - allow_gid_change: true + +ipfs-dir: + file.directory: + - name: /var/lib/ipfs + - user: ipfs + - group: ipfs + - mode: 0750 + - recurse: + - user + +ipfs-init: + cmd.run: + - name: /usr/local/sbin/ipfs init + - runas: ipfs + - cwd: /var/lib/ipfs + - success_retcodes: + - 0 + - 1 + - watch-in: + - service: ipfs-service \ No newline at end of file diff --git a/states/ipfs/ipfs.service b/states/ipfs/ipfs.service.j2 similarity index 100% rename from states/ipfs/ipfs.service rename to states/ipfs/ipfs.service.j2 diff --git a/states/ipfs/kernelmap.yaml b/states/ipfs/kernelmap.yaml new file mode 100644 index 0000000..1b57317 --- /dev/null +++ b/states/ipfs/kernelmap.yaml @@ -0,0 +1,12 @@ +--- +Linux: + os: "linux" + +Darwin: + os: "darwin" + +FreeBSD: + os: "freebsd" + +NetBSD: + os: "netbsd" \ No newline at end of file diff --git a/states/ipfs/map.jinja b/states/ipfs/map.jinja new file mode 100644 index 0000000..5c0c0ba --- /dev/null +++ b/states/ipfs/map.jinja @@ -0,0 +1,14 @@ +{%- import_yaml "golang/defaults.yaml" as default_settings -%} + +{%- import_yaml "golang/kernelmap.yaml" as kernelmap -%} +{%- import_yaml "golang/osarchmap.yaml" as osarchmap -%} + +{%- set defaults = salt['grains.filter_by'](default_settings, + default='golang', + merge=salt['grains.filter_by'](osarchmap, grain='osarch', + merge=salt['grains.filter_by'](kernelmap, grain='kernel') + ) + ) +-%} + +{%- set golang = salt['pillar.get']('golang', default=defaults, merge=True) -%} \ No newline at end of file diff --git a/states/ipfs/osarchmap.yaml b/states/ipfs/osarchmap.yaml new file mode 100644 index 0000000..493bc5a --- /dev/null +++ b/states/ipfs/osarchmap.yaml @@ -0,0 +1,21 @@ +--- +amd64: + arch: "amd64" + +x86_64: + arch: "amd64" + +386: + arch: "386" + +arm64: + arch: "arm64" + +armv6l: + arch: "armv6l" + +armv7l: + arch: "armv6l" + +armhf: + arch: "armv6l" \ No newline at end of file diff --git a/states/ipfs/service.sls b/states/ipfs/service.sls new file mode 100644 index 0000000..8a5c212 --- /dev/null +++ b/states/ipfs/service.sls @@ -0,0 +1,14 @@ +--- +ipfs-service-file: + file.managed: + - name: /etc/systemd/system/ipfs.service + - source: salt://ipfs/ipfs.service + - watch-in: + - service: ipfs-service + +ipfs-service: + service.running: + - name: ipfs + - enable: true + - require: + - file: ipfs-dir \ No newline at end of file