diff --git a/roles/operations.runner/tasks/github.yml b/roles/operations.runner/tasks/github.yml index 4f6e2ab..e418745 100644 --- a/roles/operations.runner/tasks/github.yml +++ b/roles/operations.runner/tasks/github.yml @@ -10,13 +10,18 @@ become_user: "{{ item.runner_user | default(operations_platform_user) | default('platform')}}" set_fact: # @TODO: Is there a better way to set defaults in a list of maps? - item_runner_path: "{{ user_facts.home }}/{{ item.runner_path | default('runner')}}" + item_runner_path: "{{ user_facts.home }}/{{ item.runner_path | default('runners/' ~ item.runner_repo )}}" item_runner_user: "{{ item.runner_user | default(operations_platform_user) | default('platform')}}" item_runner_name: "{{ item.runner_user | default(operations_platform_user) }}@{{ item.runner_name | default(inventory_hostname) }}" item_runner_repo: "{{ item.runner_repo | default(operations_runner_repo_default) }}" item_runner_labels: "{{ item.runner_user | default(operations_platform_user) }}@{{ item.runner_name | default(inventory_hostname) }},user/{{ item.runner_user | default(operations_platform_user) | default('platform') }},{{ item.runner_labels | default('') }}" item_runner_api_token: "{{ item.api_token | default(operations_github_api_token) }}" +- name: Ensure target directory {{ item_runner_path | dirname }} exists + file: + state: directory + path: "{{ item_runner_path | dirname }}" + - name: Copy GitHub Runner # It will fail if a job is running. ignore_errors: true @@ -50,14 +55,14 @@ failed_when: - "'token' not in github_runner_registration_token" -- name: "{{ item_runner_repo }} | Remove existing GitHub Runner" +- name: "{{ item_runner_repo }} | Remove existing GitHub Runner from {{ item_runner_path }}" shell: cmd: "./svc.sh uninstall" chdir: "{{ item_runner_path }}" become: true ignore_errors: true -- name: "{{ item_runner_repo }} | Setup GitHub Runner" +- name: "{{ item_runner_repo }} | Setup GitHub Runner in {{ item_runner_path }}" shell: cmd: "./config.sh remove --token {{ github_runner_registration_token.token }} && ./config.sh --replace --unattended --url {{ item.repo_host | default('https://github.com') }}/{{ item_runner_repo }} --token {{ github_runner_registration_token.token }} --name {{ item_runner_name }} --labels {{ item_runner_labels }}" chdir: "{{ item_runner_path }}" @@ -68,7 +73,7 @@ shell: cmd: | whoami - ./svc.sh install {{ item_runner_user }} + ./svc.sh install {{ item_runner_user }} ./svc.sh start chdir: "{{ item_runner_path }}" become: true diff --git a/roles/operations.users/defaults/main.yml b/roles/operations.users/defaults/main.yml index 69c8f99..20d85db 100644 --- a/roles/operations.users/defaults/main.yml +++ b/roles/operations.users/defaults/main.yml @@ -2,6 +2,8 @@ operations_admin_users: [] operations_control_user: control operations_control_home: /var/control +operations_control_user_groups: docker,sudo operations_platform_user: platform operations_platform_home: /var/platform +operations_platform_user_groups: docker diff --git a/roles/operations.users/tasks/main.yml b/roles/operations.users/tasks/main.yml index 5ed9518..d3e4d54 100644 --- a/roles/operations.users/tasks/main.yml +++ b/roles/operations.users/tasks/main.yml @@ -15,7 +15,7 @@ shell: /bin/bash system: true generate_ssh_key: true - groups: docker + groups: "{{ operations_platform_user_groups }}" - name: Create Platform home directory file: @@ -34,7 +34,7 @@ user: name: "{{ operations_control_user }}" group: "{{ operations_control_user }}" - groups: docker + groups: "{{ operations_control_user_groups }}" home: "{{ operations_control_home }}" uid: "{{ operations_control_user_uid | default(omit) }}" shell: /bin/bash