Cloned the linux folder and repurposed it for the DNACLAB linux machines
This commit is contained in:
parent
6a07c9deeb
commit
16be188fff
21
dnaclab_linux/get_logs.yml
Normal file
21
dnaclab_linux/get_logs.yml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
- name: Copy the contents of the "/var/log" folder to the Ansible controller
|
||||||
|
hosts: all
|
||||||
|
roles:
|
||||||
|
- common
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- name: Generate the list of files to be copied
|
||||||
|
shell: "cd /var/log; find . -maxdepth 1 -type f | cut -d'/' -f2"
|
||||||
|
register: files_to_copy
|
||||||
|
|
||||||
|
- name: Copy the log files
|
||||||
|
fetch:
|
||||||
|
src: /var/log/{{ item }}
|
||||||
|
dest: /home/vlad/Desktop/ansible/dnaclab_linux/logs/
|
||||||
|
with_items: "{{ files_to_copy.stdout_lines }}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
8
dnaclab_linux/inventory.yml
Normal file
8
dnaclab_linux/inventory.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
home:
|
||||||
|
hosts:
|
||||||
|
ubuntu.dnaclab.net:
|
||||||
|
telemetry.dnaclab.net:
|
||||||
|
developer.dnaclab.net:
|
||||||
|
gitlab.dnaclab.net:
|
||||||
|
vars:
|
||||||
|
ansible_ssh_private_key_file = /home/vlad/.ssh/id_rsa
|
||||||
14
dnaclab_linux/reboot.yml
Normal file
14
dnaclab_linux/reboot.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
- name: Reboot the Ubuntu VMs
|
||||||
|
hosts: all
|
||||||
|
gather_facts: no
|
||||||
|
roles:
|
||||||
|
- common
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- name: Rebooting...
|
||||||
|
reboot:
|
||||||
|
msg: "Reboot initiated by Ansible"
|
||||||
|
test_command: uptime
|
||||||
10
dnaclab_linux/roles/common/vars/main.yml
Normal file
10
dnaclab_linux/roles/common/vars/main.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
$ANSIBLE_VAULT;1.1;AES256
|
||||||
|
34323466633533666237623830316138373237326134336236613536633664373564633163613230
|
||||||
|
3938393338663632613061646365613630373635613536360a613039306363616432633030306334
|
||||||
|
33353839346339393965616234323561306338626533363238306662383938626364303061633332
|
||||||
|
6230623361393438610a383230376431373034306331376536313831633366373665393866373338
|
||||||
|
65313334623131323931353436623265623033396266623364313934383865386532623630336164
|
||||||
|
32653432613065303363303730353864353739633530376637333662303134613339353062303932
|
||||||
|
33646466383561373264333734626364663763393766666664653365386230393562626563376265
|
||||||
|
63303939363932636266303566363062643166343064343762313339353839326361383062653036
|
||||||
|
6232
|
||||||
46
dnaclab_linux/update_apt.yml
Normal file
46
dnaclab_linux/update_apt.yml
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
---
|
||||||
|
- name: Update and upgrade packages on Ubuntu VMs
|
||||||
|
hosts: all
|
||||||
|
roles:
|
||||||
|
- common
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- name: Update package repositories
|
||||||
|
apt: update_cache=yes force_apt_get=yes cache_valid_time=3600
|
||||||
|
|
||||||
|
- name: Get the list of upgradable packages
|
||||||
|
apt: upgrade=dist
|
||||||
|
check_mode: yes
|
||||||
|
register: upgradable_packages
|
||||||
|
|
||||||
|
- name: Print list of upgradable packages
|
||||||
|
debug:
|
||||||
|
var: upgradable_packages.stdout_lines
|
||||||
|
|
||||||
|
- name: Upgrade packages on targets
|
||||||
|
apt: upgrade=dist force_apt_get=yes
|
||||||
|
|
||||||
|
- name: Remove unused packages
|
||||||
|
apt:
|
||||||
|
autoremove: yes
|
||||||
|
|
||||||
|
- name: Get uptime information
|
||||||
|
shell: "/usr/bin/uptime"
|
||||||
|
register: my_uptime
|
||||||
|
|
||||||
|
- name: Print uptime information
|
||||||
|
debug:
|
||||||
|
var: my_uptime.stdout
|
||||||
|
verbosity: 0
|
||||||
|
|
||||||
|
- name: Get interface configuration
|
||||||
|
shell: "ip address"
|
||||||
|
register: my_interfaces
|
||||||
|
|
||||||
|
- name: Print interface information
|
||||||
|
debug:
|
||||||
|
var: my_interfaces.stdout_lines
|
||||||
|
verbosity: 0
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user