Skip to content
Snippets Groups Projects
Verified Commit 180bc353 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Rework pretty much the entire thing

Remove dev_images role as we'll pull these from a docker repository instead of building them each time
Strip ContainerLab role from any tasks that don't actually install ContainerLab
Add Docker role that installs docker onto a machine
Update inventory file to include a sample cl machine in the lab
Update playbook to only install Docker and ContainerLab by applying the appropriate roles
parent 48fe4214
No related branches found
No related tags found
No related merge requests found
- name: Sanity check
hosts: dev_environments
- name: System Setup
hosts: dev_environments
become: true
roles:
- kvm
- containerlab
- dev_images
- name: System Setup
hosts: dev_environments
roles:
- dev_networks
dev_environments: dev_environments:
hosts: hosts:
test02: karel-cl-01:
ansible_host: 172.16.100.9 ansible_host: karel-cl-01
- name: Sanity check - name: Install Docker and ContainerLab
hosts: dev_environments
tasks:
- name: Ping them
ansible.builtin.ping:
- name: Show something
ansible.builtin.debug:
msg: blah blah
- name: System Setup
hosts: dev_environments hosts: dev_environments
become: true become: true
roles: roles:
- kvm - docker
- containerlab - containerlab
- dev_images
- name: System Setup
hosts: dev_environments
roles:
- dev_networks
- name: Containerlab Repository - name: ContainerLab Repository
ansible.builtin.apt_repository: ansible.builtin.apt_repository:
repo: deb [trusted=yes] https://apt.fury.io/netdevops/ / repo: deb [trusted=yes] https://apt.fury.io/netdevops/ /
state: present state: present
...@@ -6,19 +6,7 @@ ...@@ -6,19 +6,7 @@
notify: notify:
- Update apt cache - Update apt cache
- name: Install Packages - name: Install ContainerLab package
ansible.builtin.apt: ansible.builtin.apt:
pkg: pkg:
- docker.io
- containerlab - containerlab
- python3-pip
- name: Extra pip packages
ansible.builtin.pip:
name: boto3
- name: Add relevant users to docker group
ansible.builtin.user:
name: "{{ nat_user }}"
groups: docker
append: true
- name: Inspect a single image
community.docker.docker_image_info:
name: "{{ image.image_name }}:{{ image.image_tag }}"
register: image_exists
- name: Build image if necessary
when: image_exists.images | length == 0
block:
- name: Get VM image
amazon.aws.aws_s3:
aws_access_key: "{{ s3.access_key }}"
aws_secret_key: "{{ s3.secret_key }}"
region: "{{ s3.region }}"
bucket: "{{ s3.bucket }}"
object: "{{ image.vm_image }}"
dest: "$HOME/vrnetlab/{{ image.integration }}/{{ image.vm_image }}"
mode: get
- name: Build/install the docker image
community.general.make:
chdir: "$HOME/vrnetlab/{{ image.integration }}"
- name: Inspect a single image
community.docker.docker_image_info:
name: "{{ image.image_name }}:{{ image.image_tag }}"
register: image_exists
- name: Add docker image if necessary
when: image_exists.images | length == 0
block:
- name: Get VM images
amazon.aws.aws_s3:
aws_access_key: "{{ s3.access_key }}"
aws_secret_key: "{{ s3.secret_key }}"
region: "{{ s3.region }}"
bucket: "{{ s3.bucket }}"
object: "{{ image.filename }}"
dest: "/tmp/{{ image.filename }}"
mode: get
- name: Add docker images
# community.docker.docker_image doesn't work in this case
ansible.builtin.shell:
cmd: "docker image import /tmp/{{ image.filename }} {{ image.image_name }}:{{ image.image_tag }}"
- name: Remove downloaded file
ansible.builtin.file:
path: "/tmp/{{ image.filename }}"
state: absent
- name: Install Packages
ansible.builtin.apt:
pkg:
- git
- make
- name: Clone vrnetlab
ansible.builtin.git:
repo: https://github.com/hellt/vrnetlab
version: v0.8.1
dest: $HOME/vrnetlab
- name: Build vrnetlab images
ansible.builtin.include_tasks: build_image.yml
loop: "{{ vrnetlab_images }}"
loop_control:
loop_var: image
- name: Import normal images
ansible.builtin.include_tasks: import_image.yml
loop: "{{ normal_images }}"
loop_control:
loop_var: image
- name: Install required system packages
ansible.builtin.apt:
pkg:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
- python3-pip
- virtualenv
- python3-setuptools
state: latest
update_cache: true
- name: Add Docker GPG apt Key
ansible.builtin.apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker Repository
ansible.builtin.apt_repository:
repo: deb https://download.docker.com/linux/ubuntu focal stable
state: present
- name: Update apt and install docker-ce
ansible.builtin.apt:
name: docker-ce
state: latest
update_cache: true
- name: Add relevant user to docker group
ansible.builtin.user:
name: "{{ nat_user }}"
groups: docker
append: true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment