Skip to content

Commit 4e44208

Browse files
authored
Merge pull request #31 from anfimovdm/update_build_node_deployment
Actualize separate build node deployment
2 parents 49df9e8 + f51ad25 commit 4e44208

9 files changed

Lines changed: 91 additions & 68 deletions

File tree

playbooks/albs_with_separate_build_node.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
hosts: build_node_vm
1212
roles:
1313
- separate_build_node
14-
- { role: ezamriy.fail2ban, fail2ban_ignoreip: '127.0.0.1/8 192.168.0.0/24' }
1514
tags:
1615
- build-node-deploy
1716
connection: "{{ 'local' if use_local_connection else 'ssh' }}"

roles/separate_build_node/defaults/main/common.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,15 @@ base_work_dir: "/srv/alternatives"
44
home_dir: "/home/{{ service_user }}"
55
base_conf_dir: "{{ home_dir }}/.config"
66
final_conf_dir: "{{ base_conf_dir }}/castor"
7+
service_user: albs-builder
8+
service_group: albs-builder
79
build_node_working_directory: "{{ home_dir }}/albs"
10+
build_node_venv_directory: "{{ home_dir }}/.builder-venv"
11+
build_node_requirements_path: "{{ build_node_working_directory }}/albs-node/requirements.txt"
12+
powertools_repository_name: crb
813
working_directories:
914
- "{{ base_work_dir }}"
1015
- "{{ build_node_working_directory }}"
11-
- "/var/cache/pbuilder/aptcache/"
12-
- "/var/cache/pbuilder/pbuilder_envs/"
13-
- "{{ base_work_dir }}/castor/build_node/pbuilder_envs/buster-amd64/aptcache"
14-
- "{{ base_work_dir }}/castor/build_node/pbuilder_envs/bionic-amd64/aptcache"
15-
- "{{ base_work_dir }}/castor/build_node/pbuilder_envs/focal-amd64/aptcache"
16-
- "{{ base_work_dir }}/castor/build_node/pbuilder_envs/jessie-amd64/aptcache"
17-
- "{{ base_work_dir }}/castor/build_node/pbuilder_envs/stretch-amd64/aptcache"
18-
- "{{ base_work_dir }}/castor/build_node/pbuilder_envs/xenial-amd64/aptcache"
19-
- "{{ base_work_dir }}/castor/build_node/pbuilder_envs/buster-arm64/aptcache"
20-
- "{{ base_work_dir }}/castor/build_node/pbuilder_envs/buster-armhf/aptcache"
21-
- "{{ base_work_dir }}/castor/build_node/pbuilder_envs/raspbian-armhf/aptcache"
2216
- "{{ base_work_dir }}/castor/build_node"
2317
- "{{ base_work_dir }}/castor/build_node/mock_configs"
2418
- "{{ final_conf_dir }}"
Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
---
2-
os_version: "8"
2+
os_version: "9"
33
build_node_dnf_packages:
4-
- "python3"
4+
- "centpkg"
5+
- "cmake"
6+
- "cpio"
7+
- "createrepo_c"
8+
- "ef2sprogs"
9+
- "fedpkg"
510
- "gcc"
611
- "gcc-c++"
7-
- "python3-devel"
8-
- "python3-virtualenv"
9-
- "cmake"
10-
- "python3-pycurl"
12+
- "git"
13+
- "htop"
14+
- "kernel-rpm-macros"
15+
- "keyrings-filesystem"
1116
- "libicu"
1217
- "libicu-devel"
13-
- "python3-lxml"
14-
- "git"
15-
- "tree"
16-
- "mlocate"
1718
- "mc"
18-
- "createrepo_c"
19+
- "mock"
20+
- "mock-rpmautospec"
21+
- "python3"
1922
- "python3-createrepo_c"
20-
- "xmlsec1-openssl-devel"
21-
- "cpio"
22-
- "sudo"
23-
- "kernel-rpm-macros"
23+
- "python3-devel"
2424
- "python3-libmodulemd"
25-
- "dpkg-dev"
26-
- "mock"
27-
- "debootstrap"
28-
- "pbuilder"
29-
- "apt"
30-
- "apt-libs"
31-
- "python3-apt"
32-
- "keyrings-filesystem"
25+
- "python3-lxml"
26+
- "python3-pycurl"
27+
- "python3-virtualenv"
28+
- "sudo"
29+
- "tree"
3330
- "ubu-keyring"
34-
- "debian-keyring"
31+
- "xmlsec1-openssl-devel"
3532
...
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
---
22

33
- name: Allow 'wheel' group to have passwordless sudo
4-
lineinfile:
4+
ansible.builtin.lineinfile:
55
dest: /etc/sudoers
66
state: present
77
regexp: '^%wheel'
88
line: '%wheel ALL=(ALL) NOPASSWD: ALL'
99
validate: 'visudo -cf %s'
10+
11+
- name: Set SELinux mode to permissive
12+
ansible.posix.selinux:
13+
policy: targeted
14+
state: permissive
1015
...
Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22

3-
- name: Create service user
4-
user:
3+
- name: Create user "{{ service_user }}"
4+
ansible.builtin.user:
55
name: "{{ service_user }}"
66
groups: wheel, mock
77
append: yes
@@ -10,7 +10,7 @@
1010
generate_ssh_key: yes
1111

1212
- name: Create subsequent directories
13-
file:
13+
ansible.builtin.file:
1414
path: "{{ item }}"
1515
state: directory
1616
recurse: yes
@@ -19,27 +19,40 @@
1919
with_items: "{{ working_directories }}"
2020

2121
- name: Generate build node config
22-
template:
22+
ansible.builtin.template:
2323
src: build_node.j2
2424
dest: "{{ final_conf_dir }}/build_node.yml"
2525
owner: "{{ service_user }}"
2626
group: "{{ service_group }}"
2727
mode: "0644"
2828

29-
- name: Cloud build node repository
30-
git:
29+
- name: Clone albs-node repository
30+
become: yes
31+
become_user: "{{ service_user }}"
32+
ansible.builtin.git:
3133
repo: https://github.com/AlmaLinux/albs-node.git
3234
dest: "{{ build_node_working_directory }}/albs-node"
3335
clone: yes
3436
update: yes
3537
accept_hostkey: yes
3638
force: yes
3739

38-
- name: Create venv
40+
- name: Create Python virtual environment
3941
become: yes
4042
become_user: "{{ service_user }}"
41-
pip:
42-
virtualenv: "{{ build_node_venv_directory }}"
43-
virtualenv_command: "python3 -m venv"
43+
ansible.builtin.command: python3 -m venv --system-site-packages "{{ build_node_venv_directory }}"
44+
args:
45+
creates: "{{ build_node_venv_directory }}/bin/activate"
46+
47+
- name: Upgrade pip in virtualenv
48+
become: yes
49+
become_user: "{{ service_user }}"
50+
ansible.builtin.command: "{{ build_node_venv_directory }}/bin/pip install --upgrade pip"
51+
52+
- name: Install requirements into virtualenv
53+
become: yes
54+
become_user: "{{ service_user }}"
55+
ansible.builtin.pip:
4456
requirements: "{{ build_node_requirements_path }}"
45-
virtualenv_site_packages: yes
57+
virtualenv: "{{ build_node_venv_directory }}"
58+
...
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
---
22

33
- name: Update system packages
4-
dnf:
4+
ansible.builtin.dnf:
55
name: "*"
66
state: latest
77
register: update_state
88

99
- name: Reboot a machine
10-
reboot:
10+
ansible.builtin.reboot:
1111
reboot_timeout: 180
1212
when: update_state.changed
1313

1414
- name: Install epel repository
15-
dnf:
16-
name: "epel-release"
15+
ansible.builtin.dnf:
16+
name: epel-release
1717
state: latest
1818

1919
- name: Install build system repository
20-
yum_repository:
20+
ansible.builtin.yum_repository:
2121
name: "buildnode"
2222
file: "buildnode"
2323
description: "Repository with dependencies for albs-node code"
2424
baseurl: https://repo.almalinux.org/build_system/{{ os_version }}/$basearch/
2525
enabled: no
2626
gpgcheck: no
2727

28-
- name: Install DNF packages
29-
dnf:
28+
- name: Install required system packages packages
29+
ansible.builtin.dnf:
3030
name: "{{ build_node_dnf_packages }}"
3131
state: latest
3232
enablerepo:
33-
- "epel"
34-
- "buildnode"
33+
- epel
34+
- buildnode
3535
- "{{ powertools_repository_name }}"
3636
update_cache: yes
3737
...

roles/separate_build_node/tasks/install_systemd_service.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
- name: Create build node systemd service
3-
template:
4-
dest: "/etc/systemd/system/albs-build-node.service"
5-
src: "albs_build_node.service.j2"
6-
group: "root"
7-
owner: "root"
8-
mode: "0644"
3+
ansible.builtin.template:
4+
dest: /etc/systemd/system/albs-build-node.service
5+
src: albs_build_node.service.j2
6+
group: root
7+
owner: root
8+
mode: 0644
99

1010
- name: Enable and start build node systemd service
11-
systemd:
12-
name: "albs-build-node.service"
11+
ansible.builtin.systemd:
12+
name: albs-build-node.service
1313
masked: no
1414
state: restarted
1515
daemon_reload: yes
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[Unit]
22
Description=ALBS build node
3+
After=network.target remote-fs.target
34

45
[Service]
56
RemainAfterExit=no
@@ -8,7 +9,7 @@ RestartSec=5s
89
Type=simple
910
User={{ service_user }}
1011
Group={{ service_group }}
11-
ExecStart={{ build_node_venv_directory }}/bin/python3 {{ build_node_working_directory }}/albs-node/almalinux_build_node.py
12+
ExecStart=/bin/bash -c "{{ build_node_venv_directory }}/bin/python3 {{ build_node_working_directory }}/albs-node/almalinux_build_node.py"
1213

1314
[Install]
1415
WantedBy=multi-user.target

roles/separate_build_node/templates/build_node.j2

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
---
22
master_url: "{{ albs_api_url }}"
3-
base_arch: "{{ machine_arch }}"
43
threads_count: {{ threads_count | default(4) }}
4+
base_arch: "{{ machine_arch }}"
5+
build_src: {{ build_src | default(True) }}
6+
{% if exclusions_url is defined and exclusions_url %}
7+
exclusions_url: "{{ exclusions_url }}"
8+
{% endif %}
59
jwt_token: "{{ albs_jwt_token }}"
610
pulp_host: "{{ pulp_host }}"
711
pulp_user: "{{ pulp_user }}"
812
pulp_password: "{{ pulp_password }}"
13+
pulp_uploader_max_workers: {{ pulp_uploader_workers | default(2) }}
14+
{% if sentry_dsn is defined and sentry_dsn %}
15+
sentry_dsn: "{{ sentry_dsn }}"
16+
{% endif %}
17+
{% if sentry_traces_sample_rate is defined and sentry_traces_sample_rate %}
18+
sentry_traces_sample_rate: {{ sentry_traces_sample_rate }}
19+
{% endif %}
20+
{% if sentry_environment is defined and sentry_environment %}
21+
sentry_environment: {{ sentry_environment }}
22+
{% endif %}
923
{% if immudb_address is defined and immudb_address %}
1024
immudb_address: "{{ immudb_address }}"
1125
{% endif %}
@@ -17,4 +31,4 @@ immudb_username: "{{ immudb_username }}"
1731
{% endif %}
1832
{% if immudb_password is defined and immudb_password %}
1933
immudb_password: "{{ immudb_password }}"
20-
{% endif %}
34+
{% endif %}

0 commit comments

Comments
 (0)