Files
psi.bec/tasks/main.yaml
T

168 lines
4.8 KiB
YAML

---
- name: Install and configure redis
include_role:
name: geerlingguy.redis
vars:
redis_bind_interface: 0.0.0.0
when: not ansible_check_mode
- name: Install required rpm packages
ansible.builtin.dnf:
name:
- python3.11
- git
- tmux
state: present
- name: Download epics_contexts.yml
ansible.builtin.uri:
url: https://git.psi.ch/gfa_rpms/gfa-global-profile/-/raw/master/src/etc/epics_contexts.yml
dest: /etc
- name: Download gfa_12_epics.sh
ansible.builtin.uri:
url: https://git.psi.ch/gfa_rpms/gfa-global-profile/-/raw/master/src/etc/profile.d/gfa_12_epics.sh
dest: /etc/profile.d
- name: Create a folder for BEC deployment
become_user: "{{ bec_user }}"
ansible.builtin.file:
path: "{{ bec_path }}"
state: directory
- name: Clone BEC repository
become_user: "{{ bec_user }}"
ansible.builtin.git:
repo: https://gitlab.psi.ch/bec/bec.git
dest: "{{ bec_path }}/bec"
version: "{{ bec_version }}"
- name: Clone Ophyd Devices repository
become_user: "{{ bec_user }}"
ansible.builtin.git:
repo: https://gitlab.psi.ch/bec/ophyd_devices.git
dest: "{{ bec_path }}/ophyd_devices"
version: "{{ ophyd_devices_version }}"
- name: Clone BEC Widgets repository
become_user: "{{ bec_user }}"
ansible.builtin.git:
repo: https://gitlab.psi.ch/bec/bec_widgets.git
dest: "{{ bec_path }}/bec_widgets"
version: "{{ bec_widgets_version }}"
- name: Create user branches in git repositories
become_user: "{{ bec_user }}"
ansible.builtin.command:
cmd: git switch -c {{ bec_user_branch_name }}
chdir: "{{ bec_path }}/{{ item }}"
loop:
- bec
- ophyd_devices
- bec_widgets
when: not ansible_check_mode
- name: Clone BEC plugins
become_user: "{{ bec_user }}"
ansible.builtin.git:
repo: https://oauth2:{{ lookup('env', 'BEC_PLUGIN_TOKEN') }}@gitlab.psi.ch/bec/{{ item.key }}.git
dest: "{{ bec_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: "{{ bec_user }}"
ansible.builtin.command:
cmd: git remote set-url origin https://gitlab.psi.ch/bec/{{ item.key }}.git
chdir: "{{ bec_path }}/{{ item.key }}"
loop: "{{ bec_plugins | dict2items }}"
when: not ansible_check_mode
- name: Create user branches in git repositories of plugins
become_user: "{{ bec_user }}"
ansible.builtin.command:
cmd: git switch -c {{ bec_user_branch_name }}
chdir: "{{ bec_path }}/{{ item.key }}"
loop: "{{ bec_plugins | dict2items }}"
when: not ansible_check_mode
- name: Install bec_lib
become_user: "{{ bec_user }}"
ansible.builtin.pip:
name: "{{ bec_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: "{{ bec_user }}"
ansible.builtin.pip:
name: "{{ bec_path }}/bec/bec_ipython_client"
editable: true
virtualenv_command: python3.11 -m venv
virtualenv: "{{ bec_venv_path }}"
- name: Install ophyd_devices
become_user: "{{ bec_user }}"
ansible.builtin.pip:
name: "{{ bec_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: "{{ bec_user }}"
ansible.builtin.pip:
name: "{{ bec_path }}/bec_widgets[pyside6]"
editable: true
virtualenv_command: python3.11 -m venv
virtualenv: "{{ bec_venv_path }}"
- name: Install bec_server
become_user: "{{ bec_user }}"
ansible.builtin.pip:
name: "{{ bec_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: "{{ bec_user }}"
ansible.builtin.pip:
name: "{{ bec_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: Copy BEC service config
become_user: "{{ bec_user }}"
ansible.builtin.template:
src: bec_config.yaml.j2
dest: "{{ bec_path }}/bec_config.yaml"
notify:
- (Re-)start BEC server
- name: Create a link to the current deployment
become_user: "{{ bec_user }}"
ansible.builtin.file:
src: "{{ bec_path }}"
dest: "{{ bec_deployments_path }}/bec_deployment"
state: link
- name: Activate bec venv in new terminals
become_user: "{{ bec_user }}"
ansible.builtin.blockinfile:
path: ~/.bashrc
marker: "# {mark} ANSIBLE MANAGED BLOCK (activate bec venv)"
block: source {{ bec_venv_path }}/bin/activate