infra-role-beacon-node-windows/tasks/build.yml

76 lines
2.3 KiB
YAML

---
- name: Clone Git repository
win_shell: |
git --no-pager clone \
{{ beacon_node_repo_url }} \
{{ beacon_node_repo_path }} \
--branch {{ beacon_node_repo_branch }}
args:
creates: '{{ beacon_node_repo_path }}'
- name: Allow admin user to use nimbus user repos
win_shell: |
git config --global --replace-all safe.directory '*'
- name: Fix repo folder ownership
win_acl:
path: '{{ beacon_node_repo_path }}'
user: '{{ beacon_node_service_user_name }}'
rights: 'FullControl'
inherit: 'ContainerInherit, ObjectInherit'
type: 'allow'
- name: Update Git repo branch
become: true
become_user: '{{ beacon_node_service_user_name }}'
win_shell: |
git checkout --force {{ beacon_node_repo_branch }}
args:
chdir: '{{ beacon_node_repo_path }}'
- name: Create build script
win_template:
src: 'build.sh.j2'
dest: '{{ beacon_node_service_path }}\build.sh'
mode: 0750
- name: Schedule and start node builds
win_scheduled_task:
description: 'Daily rebuild of Nimbus beacon node binaries'
name: '{{ beacon_node_build_service_name }}'
username: SYSTEM
actions:
- path: 'C:\ProgramData\scoop\apps\git\current\bin\bash.exe'
arguments: '-c "./build.sh > logs/build.log 2>&1"'
working_directory: '{{ beacon_node_service_path }}'
triggers:
- type: '{{ beacon_node_build_frequency }}'
start_boundary: '{{ ansible_date_time.date }}T{{ beacon_node_build_start_time }}'
state: 'present'
enabled: true
multiple_instances: 2 # Wait for running task
start_when_available: true
disallow_start_if_on_batteries: false
stop_if_going_on_batteries: false
- name: Check if binary exists
win_stat:
path: '{{ beacon_node_service_exe }}'
register: beacon_node_exe
# Start it right away so we have the binary to run.
- name: Start the new scheduled task
win_shell: 'Start-ScheduledTask -TaskName {{ beacon_node_build_service_name }}'
when: not beacon_node_exe.stat.exists
- name: Wait for the node build to finish (SLOW)
win_scheduled_task_stat:
name: '{{ beacon_node_build_service_name }}'
when: not beacon_node_exe.stat.exists
register: task_stat
until: |
task_stat.state is defined and
task_stat.state.status != "TASK_STATE_RUNNING"
retries: 60 # 1 hour total
delay: 60 # seconds