-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite.yml
79 lines (68 loc) · 1.68 KB
/
site.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
---
- name: tasks
hosts: localhost
vars:
- apt_packages:
- python3
- python3-pip
- python3-venv
- pip3_packages:
- sqlalchemy
- dateparser
- python-telegram-bot
tasks:
- name: Upgrade all packages to the latest version
apt:
update_cache: yes
name: "*"
state: latest
- name: Remove useless packages from the cache
apt:
autoclean: yes
- name: Remove dependencies that are no longer required
apt:
autoremove: yes
- name: "Install packages defined in apt_packages"
apt:
name: "{{ item }}"
state: latest
loop: "{{ apt_packages }}"
when: apt_packages|default([])|count > 0
- name: Create directory /venvs if it does not exist
file:
path: /venvs
state: directory
mode: '0755'
- name: Create the initial virtualenv
command:
cmd: "python3 -m venv /venvs/venv"
creates: "/venvs/venv"
- name: "Install python pip requirements defined in pip3_packages"
pip:
name: "{{ item }}"
state: forcereinstall
virtualenv: /venvs/venv
loop: "{{ pip3_packages }}"
when: pip3_packages|default([])|count > 0
- name: 'collect files'
find:
paths: "/var/lib/apt/lists/"
hidden: true
recurse: true
register: collected_files
- name: 'collect directories'
find:
paths: "/var/lib/apt/lists/"
hidden: true
recurse: true
file_type: directory
register: collected_directories
- name: remove collected files and directories
file:
path: "{{ item.path }}"
state: absent
with_items: >
{{
collected_files.files
+ collected_directories.files
}}