forked from cps-deployments/psi.bec
bec_user -> deployment_user bec_service_user -> service_user bec_deployments_path -> deployment_path_prefix bec_path -> deployment_path
206 lines
5.9 KiB
YAML
206 lines
5.9 KiB
YAML
---
|
|
- name: Edit redis config on rhel9
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/redis/redis.conf
|
|
regexp: '^bind '
|
|
line: bind * -::*
|
|
when: ansible_distribution_major_version == "9"
|
|
notify:
|
|
- Restart redis
|
|
|
|
- name: Edit redis config on rhel8
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/redis.conf
|
|
regexp: '^bind '
|
|
line: bind 0.0.0.0
|
|
when: ansible_distribution_major_version == "8"
|
|
notify:
|
|
- Restart redis
|
|
|
|
- name: EPICS setup
|
|
include_tasks: epics_setup.yaml
|
|
|
|
- name: Create a folder for BEC deployment
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.file:
|
|
path: "{{ deployment_path }}"
|
|
state: directory
|
|
|
|
- name: Clone BEC repository
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.git:
|
|
repo: https://github.com/bec-project/bec.git
|
|
dest: "{{ deployment_path }}/bec"
|
|
version: "{{ bec_version }}"
|
|
|
|
- name: Clone Ophyd Devices repository
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.git:
|
|
repo: https://github.com/bec-project/ophyd_devices.git
|
|
dest: "{{ deployment_path }}/ophyd_devices"
|
|
version: "{{ ophyd_devices_version }}"
|
|
|
|
- name: Clone BEC Widgets repository
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.git:
|
|
repo: https://github.com/bec-project/bec_widgets.git
|
|
dest: "{{ deployment_path }}/bec_widgets"
|
|
version: "{{ bec_widgets_version }}"
|
|
|
|
- name: Create user branches in git repositories
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.command:
|
|
cmd: git switch -c {{ user_git_branch_name }}
|
|
chdir: "{{ deployment_path }}/{{ item }}"
|
|
loop:
|
|
- bec
|
|
- ophyd_devices
|
|
- bec_widgets
|
|
when: not ansible_check_mode
|
|
|
|
- name: Clone BEC plugins
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.git:
|
|
repo: https://oauth2:{{ lookup('env', 'BEC_PLUGIN_TOKEN') }}@gitlab.psi.ch/bec/{{ item.key }}.git
|
|
dest: "{{ deployment_path }}/{{ item.key }}"
|
|
version: "{{ item.value or 'main' }}"
|
|
loop: "{{ bec_plugins | dict2items }}"
|
|
when: not ansible_check_mode
|
|
|
|
- name: Clear token from git remote url in BEC plugins
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.command:
|
|
cmd: git remote set-url origin https://gitlab.psi.ch/bec/{{ item.key }}.git
|
|
chdir: "{{ deployment_path }}/{{ item.key }}"
|
|
loop: "{{ bec_plugins | dict2items }}"
|
|
when: not ansible_check_mode
|
|
|
|
- name: Create user branches in git repositories of plugins
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.command:
|
|
cmd: git switch -c {{ user_git_branch_name }}
|
|
chdir: "{{ deployment_path }}/{{ item.key }}"
|
|
loop: "{{ bec_plugins | dict2items }}"
|
|
when: not ansible_check_mode
|
|
|
|
- name: Install bec_lib
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.pip:
|
|
name: "{{ deployment_path }}/bec/bec_lib"
|
|
editable: true
|
|
virtualenv_command: python3.11 -m venv
|
|
virtualenv: "{{ bec_venv_path }}"
|
|
notify:
|
|
- (Re-)start BEC server
|
|
|
|
- name: Install bec_ipython_client
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.pip:
|
|
name: "{{ deployment_path }}/bec/bec_ipython_client"
|
|
editable: true
|
|
virtualenv_command: python3.11 -m venv
|
|
virtualenv: "{{ bec_venv_path }}"
|
|
|
|
- name: Install ophyd_devices
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.pip:
|
|
name: "{{ deployment_path }}/ophyd_devices"
|
|
editable: true
|
|
virtualenv_command: python3.11 -m venv
|
|
virtualenv: "{{ bec_venv_path }}"
|
|
notify:
|
|
- (Re-)start BEC server
|
|
|
|
- name: Install bec_widgets
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.pip:
|
|
name: "{{ deployment_path }}/bec_widgets[pyside6]"
|
|
editable: true
|
|
virtualenv_command: python3.11 -m venv
|
|
virtualenv: "{{ bec_venv_path }}"
|
|
|
|
- name: Install bec_server
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.pip:
|
|
name: "{{ deployment_path }}/bec/bec_server"
|
|
editable: true
|
|
virtualenv_command: python3.11 -m venv
|
|
virtualenv: "{{ bec_venv_path }}"
|
|
notify:
|
|
- (Re-)start BEC server
|
|
|
|
- name: Install BEC plugins
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.pip:
|
|
name: "{{ deployment_path }}/{{ item.key }}"
|
|
editable: true
|
|
virtualenv_command: python3.11 -m venv
|
|
virtualenv: "{{ bec_venv_path }}"
|
|
loop: "{{ bec_plugins | dict2items }}"
|
|
notify:
|
|
- (Re-)start BEC server
|
|
|
|
- name: Create BEC deployment config directory
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.file:
|
|
path: "{{ deployment_path }}/bec/deployment_configs"
|
|
state: directory
|
|
|
|
- name: Copy BEC service config
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.template:
|
|
src: bec_config_server.yaml.j2
|
|
dest: "{{ deployment_path }}/bec/deployment_configs/server.yaml"
|
|
notify:
|
|
- (Re-)start BEC server
|
|
|
|
- name: Copy BEC client config
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.template:
|
|
src: bec_config_client.yaml.j2
|
|
dest: "{{ deployment_path }}/bec/deployment_configs/client.yaml"
|
|
|
|
- name: Copy BEC service files
|
|
ansible.builtin.template:
|
|
src: bec-server.service.j2
|
|
dest: /etc/systemd/system/bec-server.service
|
|
notify:
|
|
- (Re-)start BEC server
|
|
|
|
- name: Copy BEC service scripts
|
|
ansible.builtin.template:
|
|
src: bec-server.sh.j2
|
|
dest: /usr/local/sbin/bec-server.sh
|
|
mode: u+x
|
|
notify:
|
|
- (Re-)start BEC server
|
|
|
|
- name: Create a link to the current deployment
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.file:
|
|
src: "{{ deployment_path }}"
|
|
dest: "{{ deployment_path_prefix }}/{{ deployment_name }}"
|
|
state: link
|
|
when: not ansible_check_mode
|
|
|
|
- name: Copy BEC set account binary
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.copy:
|
|
src: bec_set_account
|
|
dest: "{{ deployment_path }}/bec/bin/bec_set_account/"
|
|
mode: u+x,g=x,o=
|
|
|
|
- name: Copy BEC set account script
|
|
become_user: "{{ deployment_user }}"
|
|
ansible.builtin.template:
|
|
src: bec-set-account.j2
|
|
dest: "{{ deployment_path }}/bec-set-account"
|
|
mode: u+x,g=x,o=
|
|
|
|
# BEC client-related tasks
|
|
- name: Add bec startup script
|
|
ansible.builtin.template:
|
|
src: bec.j2
|
|
dest: /usr/local/bin/bec
|
|
mode: "0755"
|