-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook.yml
110 lines (98 loc) · 2.66 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
---
- hosts: all
become: yes
become_method: sudo
remote_user: bench
tasks:
- name: Ensure group "bench" exists
ansible.builtin.group:
name: bench
state: present
- name: Add the user 'bench' with admin permissions
ansible.builtin.user:
name: bench
comment: Bench user to run benchmark
password: "{{ 'bench' | password_hash('sha512','A512') }}"
shell: /bin/bash
groups: sudo,bench
append: yes
- name: Update and upgrade apt packages
become: true
ansible.builtin.apt:
upgrade: yes
update_cache: yes
cache_valid_time: 86400
- name: Install Apache2
become: true
ansible.builtin.apt:
name: apache2
state: latest
- name: Install nginx
become: true
ansible.builtin.apt:
name: nginx
state: latest
- name: Install pyenv deps
become: true
ansible.builtin.apt:
pkg:
- make
- acl
- build-essential
- libssl-dev
- zlib1g-dev
- libbz2-dev
- libreadline-dev
- libsqlite3-dev
- wget
- curl
- llvm
- libncurses5-dev
- xz-utils
- tk-dev
- libffi-dev
- liblzma-dev
- python-openssl
- git
state: latest
- name: Clone pyenv repo
git:
repo: https://github.com/pyenv/pyenv.git
dest: /usr/bin/.pyenv
version: master
update: yes
- name: Clone Virtualenv repo
git:
repo: https://github.com/pyenv/pyenv-virtualenv.git
dest: /usr/bin/.pyenv/plugins/pyenv-virtualenv
version: master
update: yes
- name: Install python 3.10.4 for all users
become: yes
ansible.builtin.shell: /usr/bin/.pyenv/plugins/python-build/bin/python-build 3.10.4 /usr/local/
environment:
PYTHON_CONFIGURE_OPTS: "--enable-shared"
args:
executable: /bin/bash
- name: Copy files into /home/bench
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{item.mode}}"
owner: bench
group: bench
with_items:
- { src: './setup.sh', dest: '/home/bench/setup.sh', mode: '0555'}
- { src: './flask-example/dist/flask_example-0.1.0-py3-none-any.whl', dest: '/home/bench/dist/', mode: '0777'}
- { src: './fastapi-example/dist/fastapi_example-0.1.0-py3-none-any.whl', dest: '/home/bench/dist/', mode: '0777'}
- name: Change directory permissions
ansible.builtin.file:
path: "{{ item.dir }}"
state: directory
recurse: yes
mode: '0777'
with_items:
- { dir: '/opt/lib' }
- { dir: '/opt/bin/.pyenv' }
- { dir: '/opt/src' }
- { dir: '/opt/venv'}