-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook.yml
117 lines (99 loc) · 3.51 KB
/
playbook.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
# run provision and build tasks on all hosts (various groups specified below)
# hosts: all handles tasks for all hosts and gets variables from all.yml
- name: Build environment for running bactopia
hosts: all
become: true
vars_files:
- "{{ inventory_dir }}/group_vars/all.yml"
pre_tasks:
- name: Get current server users
ansible.builtin.getent:
database: passwd
fail_key: true
- name: "Ensure bactopia service added to user: {{ bactopia_user }}"
ansible.builtin.user:
name: "{{ bactopia_user }}"
shell: /sbin/nologin
comment: "bactopia system user"
state: present
with_items: "{{ bactopia_user }}"
when: bactopia_user not in ansible_facts.getent_passwd
- name: Install git
ansible.builtin.yum:
name: git
state: present
- name: Install docker
ansible.builtin.yum:
name: docker
state: present
- name: "Add user to docker group: {{ bactopia_user }}"
ansible.builtin.user:
name: "{{ bactopia_user }}"
append: true
groups: docker
- name: Enable and start docker service
ansible.builtin.systemd:
daemon_reload: true
name: docker
enabled: true
state: started
- name: Download Miniconda3
ansible.builtin.get_url:
url: https://repo.anaconda.com/miniconda/Miniconda3-py311_23.9.0-0-Linux-x86_64.sh
dest: /tmp/install-miniconda3.sh
checksum: sha256:43651393236cb8bb4219dcd429b3803a60f318e5507d8d84ca00dafa0c69f1bb
mode: "0550"
- name: Create conda folder
become: true
ansible.builtin.file:
path: /opt/miniconda3
state: directory
owner: root
mode: "0755"
recurse: true
- name: Install conda
ansible.builtin.command: |
/tmp/install-miniconda3.sh -b -u -p /opt/miniconda3
changed_when: false
- name: Remove conda installer
ansible.builtin.file:
state: absent
path: /tmp/install-miniconda3.sh
- name: Add conda bin to path on login
ansible.builtin.lineinfile:
path: /etc/profile
line: "export PATH=/opt/miniconda3/bin:$PATH"
create: true
mode: "0644"
- name: Initialize conda on login
become: true
ansible.builtin.file:
src: /opt/miniconda3/etc/profile.d/conda.sh
dest: /etc/profile.d/conda.sh
state: link
- name: Allow all to read conda folder
become: true
ansible.builtin.file:
path: /opt/miniconda3
mode: +r
recurse: true
- name: Allow execution for conda binaries
become: true
ansible.builtin.file:
path: /opt/miniconda3/bin
mode: +x
recurse: true
- name: Instantiate bactopia environment
ansible.builtin.command: |
bash -l -c 'conda create -n bactopia -c conda-forge -c bioconda bactopia -y'
changed_when: false
- name: Activate bactopia environment on login
ansible.builtin.lineinfile:
path: /etc/profile
line: "conda activate bactopia"
- name: Copy bactopia run script to the VM
ansible.builtin.copy:
src: files/run-bactopia-local.sh
dest: /home/vagrant/run-bactopia-local.sh
mode: "755"