deploy/plays/executionnodes.yml
- hosts: executionnodes
tasks:
- name: Create the required directories for storing security keys
file:
path: "{{ install_dir }}/{{ item }}"
state: directory
owner: "{{ ansible_user }}"
mode: 0755
with_items:
- "deploy/keys/execution_nodes/{{ inventory_hostname }}"
- "deploy/keys/gitlab/execution_nodes/{{ inventory_hostname }}"
- name: Generate certificate for execution node
include_tasks: tasks/createCert.yml
vars:
domain: "deploy/keys/execution_nodes/{{ inventory_hostname }}"
common_name: "{{ inventory_hostname }}.{{ organization }}"
- copy:
src: "{{ install_dir }}/deploy/keys/execution_nodes/{{ inventory_hostname }}/"
dest: "{{ install_dir }}/execution_nodes/{{ inventory_hostname }}/ssl/"
mode: 0755
- name: Generate ssh login keys for Gitlab
include_tasks: tasks/sshKeyGen.yml
vars:
path: "deploy/keys/gitlab/execution_nodes/{{ inventory_hostname }}"
comment: "load balancer key for {{ inventory_hostname }}@autolabjs"
- name: Register public key
shell: "cat {{ install_dir }}/deploy/keys/gitlab/execution_nodes/{{ inventory_hostname }}/id_rsa.pub"
register: ssh_key
- name: Get Private Token
uri:
url: https://{{ gitlab_hostname }}/api/v3/session
status_code: 201
method: POST
body: "login=root&password={{ gitlab_password }}"
validate_certs: no
return_content: yes
register: session_json
- set_fact:
session: "{{ session_json.content | from_json }}"
- name: Add key to gitlab
uri:
url: https://{{ gitlab_hostname }}/api/v3/user/keys
status_code: 201
method: POST
body_format: json
HEADER_PRIVATE-TOKEN: "{{ session.private_token }}"
body:
title: "execution-node-{{ ansible_host }}-{{ en_port }}"
key: "{{ ssh_key.stdout }}"
validate_certs: no
return_content: yes
- name: Build executionnode
become: yes
docker_image:
name: execution_node
path: "{{ install_dir }}/execution_nodes/{{ inventory_hostname }}"
- name: Start execution_node container
become: yes
docker_container:
name: "execution-node-{{ ansible_host }}-{{ en_port }}"
image: execution_node
network_mode: host
detach: yes
restart_policy: always
volumes:
- "{{ install_dir }}/execution_nodes/{{ inventory_hostname }}:/execution_nodes"
- "/etc/localtime:/etc/localtime:ro"
- "{{ install_dir }}/deploy/configs/execution_nodes/{{ inventory_hostname }}:/etc/execution_node"
- "{{ install_dir }}/deploy/keys/gitlab/execution_nodes/{{ inventory_hostname }}:/root/.ssh/"
- "{{ install_dir }}/util:/util"
- "{{ install_dir }}/deploy/configs/util:/etc/util"
- "{{ install_dir }}/log/execution_nodes/{{ inventory_hostname }}:/log"
env:
LOGGERCONFIG: "/etc/util/logger.json"
GITLAB_IP: "{{ gitlab_hostname }}"
ENCONFIG: "/etc/execution_node/conf.json"
ENSCORES: "/etc/execution_node/scores.json"