configurations-ansible/roles/ipfs/tasks/main.yml

77 lines
2.4 KiB
YAML

---
# tasks file for ipfs
- name: Install IPFS if enabled
when:
- 'ipfs_enabled is true'
block:
- name: Setup ipfs-update
when: 'ipfs_setup is true'
block:
- name: Create ipfs group
group:
name: "{{ ipfs_group }}"
state: present
- name: Create ipfs user
user:
name: "{{ ipfs_user }}"
state: present
shell: /sbin/nologin
group: "{{ ipfs_group }}"
- name: Create working dir
ansible.builtin.file:
path: '/mnt/ipfs'
state: directory
owner: '{{ ipfs_user }}'
group: '{{ ipfs_group }}'
- name: Download ipfs-update for IPFS version control
ansible.builtin.unarchive:
src: 'https://dist.ipfs.tech/ipfs-update/v{{ ipfs_updater_version }}/ipfs-update_v{{ ipfs_updater_version }}_linux-{{ architecture_mapping[ansible_architecture] }}.tar.gz'
dest: /tmp
remote_src: yes
owner: root
group: root
- name: Install ipfs-update
ansible.builtin.copy:
src: /tmp/ipfs-update/ipfs-update
dest: /usr/local/bin/ipfs-update
owner: ipfs
group: ipfs
mode: '1750'
remote_src: yes
- name: Install ipfs version specified
when: 'ipfs_version is defined'
become: true
become_user: '{{ ipfs_user }}'
block:
- name: Create directory tree if not exists
ansible.builtin.file:
path: '~/{{ item.path }}'
state: directory
mode: '{{ item.mode }}'
with_community.general.filetree: '../templates/ipfs/'
when: item.state == 'directory'
- name: Create and copy hardening files
ansible.builtin.template:
src: '{{ item.src }}'
dest: '~/{{ item.path }}'
with_community.general.filetree: '../templates/ipfs/'
when: item.state == 'file'
- name: Update ipfs-update version
ansible.builtin.shell: PATH=$PATH:$HOME/.local/bin ipfs-update versions
- name: Install version
ansible.builtin.shell: PATH=$PATH:$HOME/.local/bin ipfs-update install {{ ipfs_version }}
- include_tasks: "install_{{ ansible_service_mgr }}_service.yml"
- name: Setup firewall
ansible.builtin.include_role:
name: iptables-ipfs