-
Notifications
You must be signed in to change notification settings - Fork 526
Expand file tree
/
Copy pathmain.yml
More file actions
113 lines (95 loc) · 4.4 KB
/
Copy pathmain.yml
File metadata and controls
113 lines (95 loc) · 4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
- name: Run as root
become: true
block:
- name: Install pip3 dependency
ansible.builtin.pip:
name: "{{ containerlab_pip_dependencies }}"
- name: Enable & start podman service
ansible.builtin.service:
name: podman.socket
state: started
enabled: true
- name: Fetch stable containerlab RPM
ansible.builtin.get_url:
url: https://github.com/srl-labs/containerlab/releases/download/v0.71.0/containerlab_0.71.0_linux_amd64.rpm
dest: /tmp/containerlab_0.71.0_linux_amd64.rpm
mode: '0644'
- name: Install containerlab from local RPM file
ansible.builtin.dnf:
name: /tmp/containerlab_0.71.0_linux_amd64.rpm
state: present
- name: Containerlab relabling
ansible.builtin.command:
cmd: semanage fcontext -a -t textrel_shlib_t /usr/bin/containerlab
- name: Containerlab restorecon
ansible.builtin.command:
cmd: restorecon /usr/bin/containerlab
- name: Clone advanced networking workshop git repo
ansible.builtin.git:
repo: "https://github.com/mglantz/advanced-networking-workshop"
dest: /home/{{ containerlab_lab_username }}/advanced-networking-workshop
clone: true
- name: Change ownership of cloned repo
ansible.builtin.command:
cmd: "chown {{ containerlab_lab_username }}:{{ containerlab_lab_username }} /home/{{ containerlab_lab_username }}/advanced-networking-workshop -R"
- name: Copy student bash_profile
ansible.builtin.copy:
src: files/bash_profile
dest: /home/{{ containerlab_lab_username }}/.bash_profile
owner: "{{ containerlab_lab_username }}"
group: "{{ containerlab_lab_username }}"
mode: "u=rw,g=r,o=r"
- name: Put in-place the SSH key file for the student user
ansible.builtin.copy:
src: files/advanced-networking-workshop_id_rsa
dest: /home/{{ containerlab_lab_username }}/.ssh/advanced-networking-workshop_id_rsa
owner: "{{ containerlab_lab_username }}"
group: "{{ containerlab_lab_username }}"
mode: "0600"
- name: Ensure student bashrc contains ssh-agent start
ansible.builtin.lineinfile:
path: /home/{{ containerlab_lab_username }}/.bashrc
line: "eval $(ssh-agent -s)"
- name: Ensure student bashrc contains ssh-add of containerlab key
ansible.builtin.lineinfile:
path: /home/{{ containerlab_lab_username }}/.bashrc
line: "ssh-add ~/.ssh/advanced-networking-workshop_id_rsa"
- name: Download and Install ansible collections
when: containerlab_ansible_collections_tar_url is defined
block:
- name: Download collections for student user
ansible.builtin.get_url:
url: "{{ containerlab_ansible_collections_tar_url }}"
dest: /home/{{ containerlab_lab_username }}/collections.tar.gz
owner: "{{ containerlab_lab_username }}"
group: "{{ containerlab_lab_username }}"
mode: "u=r,g-rwx,o-rwx"
- name: Pre-install collections for student user
ansible.builtin.unarchive:
src: /home/{{ containerlab_lab_username }}/collections.tar.gz
remote_src: true
dest: /home/{{ containerlab_lab_username }}/
owner: "{{ containerlab_lab_username }}"
group: "{{ containerlab_lab_username }}"
- name: Remove collections tar
ansible.builtin.file:
path: /home/{{ containerlab_lab_username }}/collections.tar.gz
state: absent
- name: Download and import Arsita cEOS container file
when: containerlab_arista_ceos_image_tar_url is defined
block:
- name: Copy Arista cEOS container file to systems
ansible.builtin.get_url:
url: "{{ containerlab_arista_ceos_image_tar_url }}"
dest: /home/{{ containerlab_lab_username }}/cEOS64-lab-4.32.0F.tar.tar
owner: "{{ containerlab_lab_username }}"
group: "{{ containerlab_lab_username }}"
mode: "u=r,g-rwx,o-rwx"
- name: Podman import on cEOS container file
command:
cmd: podman import /home/{{ containerlab_lab_username }}/cEOS64-lab-4.32.0F.tar.tar ceos:4.32.0F
- name: Remove Arista cEOS container file from systems
ansible.builtin.file:
path: /home/{{ containerlab_lab_username }}/cEOS64-lab-4.32.0F.tar.tar
state: absent