Skip to content
Snippets Groups Projects
Commit 2dc8cefd authored by Erik Reid's avatar Erik Reid
Browse files

first draft playbook

parents
No related branches found
No related tags found
No related merge requests found
dev_environments:
hosts:
vm01:
ansible_host: ubclt1
- name: Sanity check
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
become: true
roles:
- containerlab
- name: System Setup
hosts: dev_environments
roles:
- dev_network
- name: update apt cache
apt:
update_cache: yes
- name: Inspect a single image
community.docker.docker_image_info:
name: "{{ image.image_name }}:{{ image.image_tag }}"
register: image_exists
- name: Stop if image exists
meta: end_play
when: image_exists.images | length > 0
- 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:
# docker_host: "unix:/run/docker.sock"
# name: "{{ item.image_name }}"
# tag: "{{ item.image_tag }}"
# load_path: "/tmp/{{ item.filename }}"
# source: load
# state: present
# loop:
# - filename: cEOS-lab-4.28.2.1F.tar
# image_name: ceos
# image_tag: 4.28.1.1F
- 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: Containerlab Repository
ansible.builtin.apt_repository:
repo: deb [trusted=yes] https://apt.fury.io/netdevops/ /
state: present
filename: netdevops
notify:
- update apt cache
- name: Install Packages
ansible.builtin.apt:
pkg:
- docker.io
- containerlab
- python3-pip
- name: Extra pip packages
ansible.builtin.pip:
name: boto3
- name: Create images
ansible.builtin.include_tasks: import_image.yml
loop: "{{ images }}"
loop_control:
loop_var: image
s3:
access_key: AKIA6DQFYS5WRMJU4FW6
secret_key: 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
region: eu-west-3
bucket: geant-emulation-images
images:
- filename: cEOS-lab-4.28.2.1F.tar
image_name: ceos
image_tag: 4.28.1.1F
- name: Ping them
ansible.builtin.ping:
- name: Show something
ansible.builtin.debug:
msg: blah blah
# - name: System Setup
# hosts: dev_environments
# become: true
# roles:
# - containerlab
# - name: System Setup
# hosts: dev_environments
# roles:
# - dev_network
# - name: Get VM images
# amazon.aws.aws_s3:
# aws_access_key: AKIA6DQFYS5WRMJU4FW6
# aws_secret_key: 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
# region: eu-west-3
# bucket: geant-emulation-images
# object: "{{ item }}"
# dest: "/tmp/{{ item }}"
# mode: get
# loop:
# - cEOS-lab-4.27.6M.tar
# - cEOS-lab-4.28.2.1F.tar
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment