From 815a188a53ed901038ac3749f94b87cb7aa7e3a4 Mon Sep 17 00:00:00 2001 From: Karel van Klink <karel.vanklink@geant.org> Date: Thu, 30 Mar 2023 13:56:23 +0200 Subject: [PATCH] Rely on environment variables instead --- README.md | 14 +++++++------- playbook.yml | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d3bdd36..9e0d5c2 100644 --- a/README.md +++ b/README.md @@ -4,22 +4,22 @@ This playbook is used to install ContainerLab on a VM, and test network configur To run this playbook: ``` -ansible-playbook -i $the-vm-you-want-to-configure, playbook.yml -e "username=$your-username-on-registry" -e "secret_token=$your-secret-tocken" -k +ansible-playbook -i $the-vm-you-want-to-configure, playbook.yml -k ``` Please note the comma after the target. -Consider that the Docker repository and the username to login on the box are hardcoded in the playbook: +Consider that the Docker repository and the username to login on the box are passed through environment variables: ``` - name: Install Docker and ContainerLab hosts: all become: true - vars: + vars: docker: - registry_url: gitlab.geant.net:5005/docker/ci_registry <<<<<<<<<<<<<<<< - username: "{{username }}" - private_token: "{{ secret_token}}" - nat_user: nat <<<<<<<<<<<<<<<< + registry_url: gitlab.geant.net:5005/docker/ci_registry + username: "{{ lookup('ansible.builtin.env', 'GITLAB_USER' }}" + private_token: "{{ lookup('ansible.builtin.env', 'GITLAB_TOKEN' }}" + nat_user: nat <<<<<<<< username is hardcoded roles: - docker - containerlab diff --git a/playbook.yml b/playbook.yml index 83daf79..6d58500 100644 --- a/playbook.yml +++ b/playbook.yml @@ -4,8 +4,8 @@ vars: docker: registry_url: gitlab.geant.net:5005/docker/ci_registry - username: "{{username }}" - private_token: "{{ secret_token}}" + username: "{{ lookup('ansible.builtin.env', 'GITLAB_USER' }}" + private_token: "{{ lookup('ansible.builtin.env', 'GITLAB_TOKEN' }}" nat_user: nat roles: - docker -- GitLab