From bd188f069e64fef4eec1d48c49d710024447f11c Mon Sep 17 00:00:00 2001 From: Benjamin Labrecque Date: Mon, 6 Jul 2026 13:20:40 +0200 Subject: [PATCH] feature: add install ioc ansible playbook --- ansible/ansible.cfg | 2 ++ ansible/hosts.yml | 3 ++ ansible/install-ioc.yml | 43 +++++++++++++++++++++++++++++ ansible/tasks/00-create-service.yml | 0 docs/ansible.md | 10 +++++++ 5 files changed, 58 insertions(+) create mode 100644 ansible/ansible.cfg create mode 100644 ansible/hosts.yml create mode 100644 ansible/install-ioc.yml delete mode 100644 ansible/tasks/00-create-service.yml create mode 100644 docs/ansible.md diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg new file mode 100644 index 0000000..89435ea --- /dev/null +++ b/ansible/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +remote_tmp = /tmp/ansible-$USER \ No newline at end of file diff --git a/ansible/hosts.yml b/ansible/hosts.yml new file mode 100644 index 0000000..4273dc9 --- /dev/null +++ b/ansible/hosts.yml @@ -0,0 +1,3 @@ +all: + hosts: + sls-lc \ No newline at end of file diff --git a/ansible/install-ioc.yml b/ansible/install-ioc.yml new file mode 100644 index 0000000..8363e0a --- /dev/null +++ b/ansible/install-ioc.yml @@ -0,0 +1,43 @@ +- name: Install an IOC + # TODO: dev/prod + hosts: sls-lc + gather_facts: false + + #TODO: docs? + # For the git clone and git push commands to work smoothly inside this playbook, + # ensure your shell environment is passing your SSH key. Run ssh-add -l on your + # terminal before firing up ansible-playbook. + + # TODO + # If the machine executing this playbook doesn't have a global Git user configured, + # the git commit task will fail. You can explicitly bypass this by adding environment + # variables directly to the commit task if needed: + # environment: + # GIT_COMMITTER_NAME: "Ansible Provisioner" + # GIT_COMMITTER_EMAIL: "your-email@psi.ch" + # GIT_AUTHOR_NAME: "Ansible Provisioner" + # GIT_AUTHOR_EMAIL: "your-email@psi.ch" + + + # TODO: checkout repo, cd to services//ioc, 'ioc install -V --ioc AGEBD-CPCL- –clean' + vars: + - workspace_dir: "/tmp/hla_framework_bd" + - service_id: "{{ service_id }}" + - service_name_lower: "{{ service_name_lower }}" + - service_name_upper: "{{ service_name_upper }}" + + + tasks: + - name: Clone this repository + ansible.builtin.git: + repo: "git@gitea.psi.ch:sls/hla_framework_bd.git" + dest: "{{ workspace_dir }}" + version: main + accept_hostkey: true + + - name: Run ioc install + ansible.builtin.shell: + # TODO: prod/dev + cmd: "ioc install -V --facility sls --ioc AGEBD-CPCL-{{ service_name_upper }}-DEV --clean" + chdir: "{{ workspace_dir }}/services/{{ service_id }}-{{ service_name_lower }}/ioc" + changed_when: true \ No newline at end of file diff --git a/ansible/tasks/00-create-service.yml b/ansible/tasks/00-create-service.yml deleted file mode 100644 index e69de29..0000000 diff --git a/docs/ansible.md b/docs/ansible.md new file mode 100644 index 0000000..a6c3600 --- /dev/null +++ b/docs/ansible.md @@ -0,0 +1,10 @@ +# Ansible + +## Running a playbook manually + +Set vars on command line: + +``` +cd ansible +ansible-playbook install-ioc.yml -i hosts.yml --extra-vars="service_id=000 service_name_lower=master service_name_upper=MASTER" +``` \ No newline at end of file