Apply Ansible-lint
This commit is contained in:
@@ -1,119 +1,127 @@
|
|||||||
---
|
---
|
||||||
- hosts: all
|
- name: "Containerlab Installation"
|
||||||
become: yes
|
hosts: all
|
||||||
|
become: true
|
||||||
vars_files:
|
vars_files:
|
||||||
- ./clab_vars.yml
|
- ./clab_vars.yml
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
- name: Set hostname to ContainerLab
|
- name: Set hostname to ContainerLab
|
||||||
hostname:
|
ansible.builtin.hostname:
|
||||||
name: ContainerLab
|
name: ContainerLab
|
||||||
|
|
||||||
- name: Install required system packages
|
- name: Install required system packages
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
pkg:
|
pkg:
|
||||||
- apt-transport-https
|
- apt-transport-https
|
||||||
- ca-certificates
|
- ca-certificates
|
||||||
- curl
|
- curl
|
||||||
- software-properties-common
|
- software-properties-common
|
||||||
- python3-pip
|
- python3-pip
|
||||||
- virtualenv
|
- virtualenv
|
||||||
- python3-setuptools
|
- python3-setuptools
|
||||||
- git
|
- git
|
||||||
- tree
|
- tree
|
||||||
- htop
|
- htop
|
||||||
- rsync
|
- rsync
|
||||||
state: latest
|
update_cache: true
|
||||||
update_cache: true
|
|
||||||
|
|
||||||
- name: Add Docker GPG apt Key
|
- name: Add Docker GPG apt Key
|
||||||
apt_key:
|
ansible.builtin.apt_key:
|
||||||
url: https://download.docker.com/linux/ubuntu/gpg
|
url: https://download.docker.com/linux/ubuntu/gpg
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Add Docker Repository
|
- name: Add Docker Repository
|
||||||
apt_repository:
|
ansible.builtin.apt_repository:
|
||||||
repo: deb https://download.docker.com/linux/ubuntu focal stable
|
repo: deb https://download.docker.com/linux/ubuntu focal stable
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Update apt and install docker-ce
|
- name: Update apt and install docker-ce
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
name: docker-ce
|
name: docker-ce
|
||||||
state: latest
|
update_cache: true
|
||||||
update_cache: true
|
|
||||||
|
|
||||||
- name: Add the current user to the docker group
|
- name: Add the current user to the docker group
|
||||||
user:
|
ansible.builtin.user:
|
||||||
name: "{{ ansible_user_id }}"
|
name: "{{ ansible_user_id }}"
|
||||||
group: docker
|
group: docker
|
||||||
|
|
||||||
- name: Add Tailscale GPG apt Key
|
- name: Add Tailscale GPG apt Key
|
||||||
apt_key:
|
ansible.builtin.apt_key:
|
||||||
url: https://pkgs.tailscale.com/stable/ubuntu/focal.noarmor.gpg
|
url: https://pkgs.tailscale.com/stable/ubuntu/focal.noarmor.gpg
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Add Tailscale Repository
|
- name: Add Tailscale Repository
|
||||||
apt_repository:
|
ansible.builtin.apt_repository:
|
||||||
repo: deb https://pkgs.tailscale.com/stable/ubuntu/ focal main
|
repo: deb https://pkgs.tailscale.com/stable/ubuntu/ focal main
|
||||||
state: present
|
state: present
|
||||||
filename: tailscale
|
filename: tailscale
|
||||||
update_cache: yes
|
update_cache: true
|
||||||
|
|
||||||
- name: Update apt and install Tailscale
|
- name: Update apt and install Tailscale
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
name: tailscale
|
name: tailscale
|
||||||
state: latest
|
update_cache: true
|
||||||
update_cache: yes
|
|
||||||
|
|
||||||
- name: Run Tailscale CLI command
|
- name: Run Tailscale CLI command
|
||||||
command: "sudo tailscale up --authkey {{ tailscale_auth_key }}"
|
ansible.builtin.command: "sudo tailscale up --authkey {{ tailscale_auth_key }}"
|
||||||
|
register: tailscale_output
|
||||||
|
changed_when: tailscale_output.rc != 0
|
||||||
|
|
||||||
- name: Install ContainerLab
|
- name: Add ContainerLab Repository
|
||||||
shell: |
|
ansible.builtin.apt_repository:
|
||||||
curl -sL https://get.containerlab.dev | sudo bash
|
repo: deb [trusted=yes] https://apt.fury.io/netdevops/ /
|
||||||
args:
|
state: present
|
||||||
creates: /usr/local/bin/containerlab
|
filename: netdevops.list
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
- name: Ensure /opt/containerlab directory exists
|
- name: Update apt and install ContainerLab
|
||||||
file:
|
ansible.builtin.apt:
|
||||||
path: /opt/containerlab
|
name: containerlab
|
||||||
state: directory
|
update_cache: true
|
||||||
mode: '0755'
|
|
||||||
owner: admin
|
|
||||||
group: admin
|
|
||||||
become: yes
|
|
||||||
|
|
||||||
- name: Ensure user 'admin' exists
|
- name: Ensure /opt/containerlab directory exists
|
||||||
user:
|
ansible.builtin.file:
|
||||||
name: admin
|
path: /opt/containerlab
|
||||||
append: yes
|
state: directory
|
||||||
groups: docker
|
mode: '0755'
|
||||||
shell: /bin/bash
|
owner: admin
|
||||||
become: yes
|
group: admin
|
||||||
|
become: true
|
||||||
|
|
||||||
- name: Clone specified GitHub repository to /opt/containerlab
|
- name: Ensure user 'admin' exists
|
||||||
git:
|
ansible.builtin.user:
|
||||||
repo: "{{ repo_git_url }}"
|
name: admin
|
||||||
dest: "/opt/containerlab/projet/"
|
append: true
|
||||||
accept_hostkey: yes
|
groups: docker
|
||||||
clone: yes
|
shell: /bin/bash
|
||||||
update: yes
|
become: true
|
||||||
version: "main"
|
|
||||||
become: yes
|
|
||||||
when: (repo_git_url is defined) and (repo_git_url | length > 0)
|
|
||||||
|
|
||||||
- name: Synchronize local directory to VM
|
- name: Clone specified GitHub repository to /opt/containerlab
|
||||||
ansible.posix.synchronize:
|
ansible.builtin.git:
|
||||||
src: "{{ local_dir_path }}"
|
repo: "{{ repo_git_url }}"
|
||||||
dest: "/opt/containerlab/projet/"
|
dest: "/opt/containerlab/projet/"
|
||||||
recursive: yes
|
accept_hostkey: true
|
||||||
become: yes
|
clone: true
|
||||||
when: (local_dir_path is defined) and (local_dir_path | length > 0)
|
update: true
|
||||||
|
version: "main"
|
||||||
|
become: true
|
||||||
|
when: (repo_git_url is defined) and (repo_git_url | length > 0)
|
||||||
|
|
||||||
- name: Copy network images to remote /tmp directory
|
- name: Synchronize local directory to VM
|
||||||
copy:
|
ansible.posix.synchronize:
|
||||||
src: "{{ item }}"
|
src: "{{ local_dir_path }}"
|
||||||
dest: "/tmp/{{ item | basename }}"
|
dest: "/opt/containerlab/projet/"
|
||||||
with_fileglob:
|
recursive: true
|
||||||
- "../network_images/*"
|
become: true
|
||||||
when: inventory_hostname in groups['all']
|
when: (local_dir_path is defined) and (local_dir_path | length > 0)
|
||||||
|
|
||||||
|
- name: Copy network images to remote /tmp directory
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ item }}"
|
||||||
|
dest: "/tmp/{{ item | basename }}"
|
||||||
|
mode: '0755'
|
||||||
|
with_fileglob:
|
||||||
|
- "../network_images/*"
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups['all']
|
||||||
|
|||||||
Reference in New Issue
Block a user