Skip to content

Commit 85f20a1

Browse files
committed
- add support for Zabbix7
- use invidual pyhton venv (instead of global one) - bump ansible version to 10.7, minor changes over some tasks
1 parent 44e3dc2 commit 85f20a1

File tree

12 files changed

+46
-29
lines changed

12 files changed

+46
-29
lines changed

bibigrid/core/utility/ansible_commands.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"Adjust playbook home permission.")
5050
MV_ANSIBLE_CONFIG = (
5151
"sudo install -D /opt/playbook/ansible.cfg /etc/ansible/ansible.cfg", "Move ansible configuration.")
52-
EXECUTE = (f"ansible-playbook {os.path.join(a_rp.PLAYBOOK_PATH_REMOTE, a_rp.SITE_YAML)} -i "
52+
EXECUTE = (f"/opt/bibigrid-venv/bin/ansible-playbook {os.path.join(a_rp.PLAYBOOK_PATH_REMOTE, a_rp.SITE_YAML)} -i "
5353
f"{os.path.join(a_rp.PLAYBOOK_PATH_REMOTE, a_rp.ANSIBLE_HOSTS)} -l {{}}",
5454
"Execute ansible playbook. Be patient.")
5555

@@ -58,5 +58,7 @@
5858
"while [[ $(systemctl is-active {service}) == 'active' ]]; do echo 'Waiting for service {service}'; sleep 2; done",
5959
"Waiting for service {service}.")
6060
UPDATE = ("sudo apt-get update", "Update apt repository lists.")
61-
PYTHON3_PIP = "sudo apt-get install -y python3-pip", "Install python3 pip using apt."
62-
ANSIBLE_PASSLIB = ("sudo pip install ansible==6.6 passlib", "Install Ansible and Passlib using pip.")
61+
PYTHON3_PIP = ("sudo apt-get install -y python3-pip python3-venv", "Install python3 pip and venv using apt.")
62+
VENV_SETUP = ("sudo python3 -m venv /opt/bibigrid-venv"," Create bibigrid virtual environment.")
63+
ANSIBLE_PASSLIB = ("sudo /opt/bibigrid-venv/bin/pip install ansible==10.7 passlib", "Install Ansible 10.7 and Passlib using pip.")
64+
ANSIBLE_GALAXY = ("sudo /opt/bibigrid-venv/bin/ansible-galaxy collection install -p /usr/share/ansible/collections community.zabbix==3.2.0", "Install necessary ansible-galaxy modules.")

bibigrid/core/utility/handler/ssh_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from bibigrid.models.exceptions import ConnectionException, ExecutionException
1515

1616
PRIVATE_KEY_FILE = ".ssh/id_ecdsa" # to name bibigrid-temp keys identically on remote
17-
ANSIBLE_SETUP = [a_c.NO_UPDATE, a_c.UPDATE, a_c.PYTHON3_PIP, a_c.ANSIBLE_PASSLIB,
17+
ANSIBLE_SETUP = [a_c.NO_UPDATE, a_c.UPDATE, a_c.PYTHON3_PIP, a_c.VENV_SETUP, a_c.ANSIBLE_PASSLIB, a_c.ANSIBLE_GALAXY,
1818
(f"chmod 600 {PRIVATE_KEY_FILE}", "Adjust private key permissions."), a_c.PLAYBOOK_HOME,
1919
a_c.PLAYBOOK_HOME_RIGHTS, a_c.ADD_PLAYBOOK_TO_LINUX_HOME]
2020
# ANSIBLE_START = [aC.WAIT_READY, aC.UPDATE, aC.MV_ANSIBLE_CONFIG, aC.EXECUTE] # another UPDATE seems to not necessary.

resources/playbook/roles/bibigrid/files/slurm/create.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ log "Create-Script started"
3737

3838
hosts=$(scontrol show hostnames "$1")
3939

40+
# use python bibigrid environment
41+
source /opt/bibigrid-venv/bin/activate
4042

4143
# create and configure requested instances
4244
python3 /usr/local/bin/create_server.py "${hosts}"

resources/playbook/roles/bibigrid/files/slurm/create_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def _run_playbook(cmdline_args):
341341
@param cmdline_args:
342342
@return
343343
"""
344-
executable_cmd = '/usr/local/bin/ansible-playbook'
344+
executable_cmd = '/opt/bibigrid-venv/bin/ansible-playbook'
345345
logging.info(f"run_command...\nexecutable_cmd: {executable_cmd}\ncmdline_args: {cmdline_args}")
346346
runner = ansible_runner.interface.init_command_config(executable_cmd=executable_cmd, cmdline_args=cmdline_args)
347347

resources/playbook/roles/bibigrid/files/slurm/terminate.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ scontrol update NodeName="$1" state=RESUME reason=FailedStartup # no sudo needed
1414

1515
hosts=$(scontrol show hostnames "$1")
1616

17+
# use python bibigrid environment
18+
source /opt/bibigrid-venv/bin/activate
19+
1720
# delete servers
1821
python3 /usr/local/bin/delete_server.py "${hosts}"
1922

resources/playbook/roles/bibigrid/handlers/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
name: slurmd
3636
state: restarted
3737

38-
- name: zabbix-agent
38+
- name: zabbix-agent2
3939
systemd:
40-
name: zabbix-agent
40+
name: zabbix-agent2
4141
state: restarted
4242

4343
- name: zabbix-server

resources/playbook/roles/bibigrid/tasks/001-apt.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@
4848

4949
- name: Add zabbix repositories
5050
apt:
51-
deb: "https://repo.zabbix.com/zabbix/6.2/{{ ansible_distribution | lower }}\
52-
/pool/main/z/zabbix-release/zabbix-release_6.2-1%2B{{ ansible_distribution | lower }}\
53-
{{ ansible_distribution_version }}_all.deb"
51+
deb: "https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.0+{{ ansible_distribution | lower }}{{ ansible_distribution_version }}_all.deb"
5452
state: present
5553
force: true
5654
tags:

resources/playbook/roles/bibigrid/tasks/011-zabbix-agent.yaml

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
group: zabbix
2222
mode: "0o755"
2323

24-
- name: Adjust zabbix agent configuration
24+
- name: Adjust zabbix agent2 configuration
2525
template:
26-
src: zabbix/zabbix_agentd.conf.j2
27-
dest: /etc/zabbix/zabbix_agentd.conf
26+
src: zabbix/zabbix_agent2.conf.j2
27+
dest: /etc/zabbix/zabbix_agent2.conf
2828
mode: "0o644"
29-
notify: zabbix-agent
29+
notify: zabbix-agent2
3030

3131
- name: Copy Zabbix Host delete script
3232
copy:
@@ -38,9 +38,9 @@
3838
pip:
3939
name: zabbix-api
4040

41-
- name: Install zabbix agent
41+
- name: Install zabbix agent2
4242
apt:
43-
name: zabbix-agent
43+
name: zabbix-agent2
4444
state: present
4545
when: "ansible_distribution_file_variety == 'Debian'"
4646

@@ -50,9 +50,9 @@
5050
state: present
5151
when: "ansible_distribution_file_variety == 'RedHat'"
5252

53-
- name: Start and Enable zabbix-agent
53+
- name: Start and Enable zabbix-agent2
5454
systemd:
55-
name: zabbix-agent
55+
name: zabbix-agent2
5656
state: started
5757
enabled: true
5858

@@ -61,10 +61,14 @@
6161
# --------------------------------------
6262

6363
- name: Add worker node to zabbix hosts
64+
vars:
65+
ansible_network_os: community.zabbix.zabbix
66+
ansible_connection: httpapi
67+
ansible_httpapi_port: 80
68+
ansible_http_use_ssl: false
69+
ansible_user: Admin
70+
ansible_httpapi_pass: "{{ zabbix_conf.admin_password }}"
6471
zabbix_host:
65-
server_url: "http://127.0.0.1/zabbix/"
66-
login_user: Admin
67-
login_password: "{{ zabbix_conf.admin_password }}"
6872
host_name: "{{ ansible_hostname }}"
6973
visible_name: "{{ ansible_hostname }}"
7074
description: add by ansible
@@ -84,11 +88,19 @@
8488
when: "'master' not in group_names"
8589
delegate_to: localhost
8690

91+
# --------------------------------------
92+
# -- Add master node as zabbix hosts --
93+
# --------------------------------------
94+
8795
- name: Add master node to zabbix hosts
96+
vars:
97+
ansible_network_os: community.zabbix.zabbix
98+
ansible_connection: httpapi
99+
ansible_httpapi_port: 80
100+
ansible_http_use_ssl: false
101+
ansible_user: Admin
102+
ansible_httpapi_pass: "{{ zabbix_conf.admin_password }}"
88103
zabbix_host:
89-
server_url: "http://127.0.0.1/zabbix/"
90-
login_user: Admin
91-
login_password: "{{ zabbix_conf.admin_password }}"
92104
host_name: "{{ ansible_hostname }}"
93105
visible_name: "{{ ansible_hostname }}"
94106
description: add by ansible
@@ -105,4 +117,4 @@
105117
useip: 1 # connect using host IP address
106118
port: 10050
107119
become: false
108-
when: "'master' in group_names"
120+
when: "'master' in group_names"

resources/playbook/roles/bibigrid/tasks/042-slurm-server.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
mode: "0o750"
155155

156156
- name: Install python dependencies
157-
pip:
157+
ansible.builtin.pip:
158158
name:
159159
- python-openstackclient==6.0.0
160160
- openstacksdk==0.62.0
@@ -163,6 +163,7 @@
163163
- paramiko
164164
- ansible-runner
165165
- pyzabbix
166+
virtualenv: /opt/bibigrid-venv
166167

167168
- name: 'Add default user to ansible group'
168169
user:

resources/playbook/roles/bibigrid/tasks/900-theia.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
args:
4444
creates: "{{ nvm_install_dir }}/nvm.sh"
4545
executable: bash
46-
warn: false
4746
tags:
4847
- skip_ansible_lint
4948

0 commit comments

Comments
 (0)