generated from csunibo/template-it
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from jgabaut/main
feat: add esercizi/..
- Loading branch information
Showing
89 changed files
with
4,298 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Not done. |
2 changes: 2 additions & 0 deletions
2
esercizi/esercitazioni-jgabaut/DHCP/Router-2-Client-tramite-Ansible/Client1/eth1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
auto eth1 | ||
iface eth1 inet dhcp |
36 changes: 36 additions & 0 deletions
36
esercizi/esercitazioni-jgabaut/DHCP/Router-2-Client-tramite-Ansible/Client1/playbook.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
- hosts: all | ||
tasks: | ||
- name: Add file .vimrc to home directory and set no-compatibility mode for vi | ||
ansible.builtin.lineinfile: | ||
path: /home/vagrant/.vimrc | ||
line: 'set nocompatible' | ||
state: present | ||
create: yes | ||
|
||
- name: Set a hostname | ||
become: true | ||
ansible.builtin.hostname: | ||
name: Client1 | ||
|
||
- name: Fix allow-hotplug bug | ||
become: true | ||
ansible.builtin.replace: | ||
path: /etc/network/interfaces | ||
regexp: '^allow-hotplug' | ||
replace: 'auto' | ||
|
||
- name: Copy a new network configuration "interfaces" file into place, after passing validation with ifup | ||
become: true | ||
ansible.builtin.copy: | ||
src: eth1 | ||
dest: /etc/network/interfaces.d/eth1 | ||
validate: /usr/sbin/ifup --no-act -i %s eth1 | ||
notify: Restart Networking | ||
|
||
handlers: | ||
- name: Restart Networking | ||
become: true | ||
ansible.builtin.service: | ||
name: networking | ||
state: restarted |
75 changes: 75 additions & 0 deletions
75
esercizi/esercitazioni-jgabaut/DHCP/Router-2-Client-tramite-Ansible/Client1/vagrantfile.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
# All Vagrant configuration is done below. The "2" in Vagrant.configure | ||
# configures the configuration version (we support older styles for | ||
# backwards compatibility). Please don't change it unless you know what | ||
# you're doing. | ||
Vagrant.configure("2") do |config| | ||
# The most common configuration options are documented and commented below. | ||
# For a complete reference, please see the online documentation at | ||
# https://docs.vagrantup.com. | ||
|
||
# Every Vagrant development environment requires a box. You can search for | ||
# boxes at https://vagrantcloud.com/search. | ||
config.vm.box = "las/bullseye64" | ||
|
||
# Disable automatic box update checking. If you disable this, then | ||
# boxes will only be checked for updates when the user runs | ||
# `vagrant box outdated`. This is not recommended. | ||
# config.vm.box_check_update = false | ||
|
||
# Create a forwarded port mapping which allows access to a specific port | ||
# within the machine from a port on the host machine. In the example below, | ||
# accessing "localhost:8080" will access port 80 on the guest machine. | ||
# NOTE: This will enable public access to the opened port | ||
# config.vm.network "forwarded_port", guest: 80, host: 8080 | ||
|
||
# Create a forwarded port mapping which allows access to a specific port | ||
# within the machine from a port on the host machine and only allow access | ||
# via 127.0.0.1 to disable public access | ||
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" | ||
|
||
# Create a private network, which allows host-only access to the machine | ||
# using a specific IP. | ||
# config.vm.network "private_network", ip: "192.168.33.10" | ||
config.vm.network "private_network", virtualbox__intnet: "LAN1", auto_config: false | ||
|
||
# Create a public network, which generally matched to bridged network. | ||
# Bridged networks make the machine appear as another physical device on | ||
# your network. | ||
# config.vm.network "public_network" | ||
|
||
# Share an additional folder to the guest VM. The first argument is | ||
# the path on the host to the actual folder. The second argument is | ||
# the path on the guest to mount the folder. And the optional third | ||
# argument is a set of non-required options. | ||
# config.vm.synced_folder "../data", "/vagrant_data" | ||
|
||
# Provider-specific configuration so you can fine-tune various | ||
# backing providers for Vagrant. These expose provider-specific options. | ||
# Example for VirtualBox: | ||
# | ||
config.vm.provider "virtualbox" do |vb| | ||
# Display the VirtualBox GUI when booting the machine | ||
vb.linked_clone = true | ||
# vb.gui = true | ||
# | ||
# # Customize the amount of memory on the VM: | ||
# vb.memory = "1024" | ||
end | ||
# | ||
# View the documentation for the provider you are using for more | ||
# information on available options. | ||
|
||
# Enable provisioning with a shell script. Additional provisioners such as | ||
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the | ||
# documentation for more information about their specific syntax and use. | ||
# config.vm.provision "shell", inline: <<-SHELL | ||
config.vm.provision "ansible" do |ansible| | ||
ansible.playbook = "playbook.yml" | ||
end | ||
# apt-get update | ||
# apt-get install -y apache2 | ||
# SHELL | ||
end |
2 changes: 2 additions & 0 deletions
2
esercizi/esercitazioni-jgabaut/DHCP/Router-2-Client-tramite-Ansible/Client2/eth1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
auto eth1 | ||
iface eth1 inet dhcp |
37 changes: 37 additions & 0 deletions
37
esercizi/esercitazioni-jgabaut/DHCP/Router-2-Client-tramite-Ansible/Client2/playbook.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
- hosts: all | ||
tasks: | ||
|
||
- name: Add file .vimrc to home directory and set no-compatibility mode for vi | ||
ansible.builtin.lineinfile: | ||
path: /home/vagrant/.vimrc | ||
line: 'set nocompatible' | ||
state: present | ||
create: yes | ||
|
||
- name: Set a hostname | ||
become: yes | ||
ansible.builtin.hostname: | ||
name: Client2 | ||
|
||
- name: Fix allow-hotplug bug | ||
become: true | ||
ansible.builtin.replace: | ||
path: /etc/network/interfaces | ||
regexp: '^allow-hotplug' | ||
replace: 'auto' | ||
|
||
- name: Copy a new network configuration "interfaces" file into place, after passing validation with ifup | ||
become: true | ||
ansible.builtin.copy: | ||
src: ./eth1 | ||
dest: /etc/network/interfaces.d/eth1 | ||
validate: /usr/sbin/ifup --no-act -i %s eth1 | ||
notify: Restart Networking | ||
|
||
handlers: | ||
- name: Restart Networking | ||
become: true | ||
ansible.builtin.service: | ||
name: networking | ||
state: restarted |
75 changes: 75 additions & 0 deletions
75
esercizi/esercitazioni-jgabaut/DHCP/Router-2-Client-tramite-Ansible/Client2/vagrantfile.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
# All Vagrant configuration is done below. The "2" in Vagrant.configure | ||
# configures the configuration version (we support older styles for | ||
# backwards compatibility). Please don't change it unless you know what | ||
# you're doing. | ||
Vagrant.configure("2") do |config| | ||
# The most common configuration options are documented and commented below. | ||
# For a complete reference, please see the online documentation at | ||
# https://docs.vagrantup.com. | ||
|
||
# Every Vagrant development environment requires a box. You can search for | ||
# boxes at https://vagrantcloud.com/search. | ||
config.vm.box = "las/bullseye64" | ||
|
||
# Disable automatic box update checking. If you disable this, then | ||
# boxes will only be checked for updates when the user runs | ||
# `vagrant box outdated`. This is not recommended. | ||
# config.vm.box_check_update = false | ||
|
||
# Create a forwarded port mapping which allows access to a specific port | ||
# within the machine from a port on the host machine. In the example below, | ||
# accessing "localhost:8080" will access port 80 on the guest machine. | ||
# NOTE: This will enable public access to the opened port | ||
# config.vm.network "forwarded_port", guest: 80, host: 8080 | ||
|
||
# Create a forwarded port mapping which allows access to a specific port | ||
# within the machine from a port on the host machine and only allow access | ||
# via 127.0.0.1 to disable public access | ||
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" | ||
|
||
# Create a private network, which allows host-only access to the machine | ||
# using a specific IP. | ||
# config.vm.network "private_network", ip: "192.168.33.10" | ||
config.vm.network "private_network", virtualbox__intnet: "LAN2", auto_config: false | ||
|
||
# Create a public network, which generally matched to bridged network. | ||
# Bridged networks make the machine appear as another physical device on | ||
# your network. | ||
# config.vm.network "public_network" | ||
|
||
# Share an additional folder to the guest VM. The first argument is | ||
# the path on the host to the actual folder. The second argument is | ||
# the path on the guest to mount the folder. And the optional third | ||
# argument is a set of non-required options. | ||
# config.vm.synced_folder "../data", "/vagrant_data" | ||
|
||
# Provider-specific configuration so you can fine-tune various | ||
# backing providers for Vagrant. These expose provider-specific options. | ||
# Example for VirtualBox: | ||
# | ||
config.vm.provider "virtualbox" do |vb| | ||
# Display the VirtualBox GUI when booting the machine | ||
vb.linked_clone = true | ||
# vb.gui = true | ||
# | ||
# # Customize the amount of memory on the VM: | ||
# vb.memory = "1024" | ||
end | ||
# | ||
# View the documentation for the provider you are using for more | ||
# information on available options. | ||
|
||
# Enable provisioning with a shell script. Additional provisioners such as | ||
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the | ||
# documentation for more information about their specific syntax and use. | ||
config.vm.provision "ansible" do |ansible| | ||
ansible.playbook = "playbook.yml" | ||
end | ||
# config.vm.provision "shell", inline: <<-SHELL | ||
# apt-get update | ||
# apt-get install -y apache2 | ||
# SHELL | ||
end |
4 changes: 4 additions & 0 deletions
4
esercizi/esercitazioni-jgabaut/DHCP/Router-2-Client-tramite-Ansible/Router/eth1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
auto eth1 | ||
iface eth1 inet static | ||
address 10.10.1.1 | ||
netmask 255.255.255.0 |
4 changes: 4 additions & 0 deletions
4
esercizi/esercitazioni-jgabaut/DHCP/Router-2-Client-tramite-Ansible/Router/eth2.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
auto eth2 | ||
iface eth2 inet static | ||
address 10.10.2.1 | ||
netmask 255.255.255.0 |
84 changes: 84 additions & 0 deletions
84
esercizi/esercitazioni-jgabaut/DHCP/Router-2-Client-tramite-Ansible/Router/playbook.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--- | ||
- hosts: all | ||
tasks: | ||
- name: Add file .vimrc to home directory and set no-compatibility mode for vi | ||
become: true | ||
ansible.builtin.lineinfile: | ||
path: /home/vagrant/.vimrc | ||
line: 'set nocompatible' | ||
state: present | ||
create: yes | ||
|
||
- name: Set a hostname | ||
become: true | ||
ansible.builtin.hostname: | ||
name: Router | ||
|
||
- name: Fix allow-hotplug bug | ||
become: true | ||
ansible.builtin.replace: | ||
path: /etc/network/interfaces | ||
regexp: '^allow-hotplug' | ||
replace: 'auto' | ||
|
||
- name: Copy a new network configuration "interfaces" file into place, after passing validation with ifup | ||
become: true | ||
ansible.builtin.copy: | ||
src: ./eth1 | ||
dest: /etc/network/interfaces.d/eth1 | ||
validate: /usr/sbin/ifup --no-act -i %s eth1 | ||
notify: Restart Networking | ||
|
||
- name: Copy a new network configuration "interfaces" file into place, after passing validation with ifup | ||
become: true | ||
ansible.builtin.copy: | ||
src: ./eth2 | ||
dest: /etc/network/interfaces.d/eth2 | ||
validate: /usr/sbin/ifup --no-act -i %s eth2 | ||
notify: Restart Networking | ||
|
||
- name: Install dnsmasq | ||
become: true | ||
ansible.builtin.apt: | ||
name: dnsmasq | ||
state: present | ||
update_cache: yes | ||
|
||
- name: Configure DHCP range for LAN1 and LAN2 | ||
become: true | ||
ansible.builtin.blockinfile: | ||
path: /etc/dnsmasq.conf | ||
state: present | ||
create: yes | ||
block: | | ||
interface=eth1 | ||
interface=eth2 | ||
dhcp-range=set:first,10.10.1.100,10.10.1.200,12h | ||
dhcp-range=set:second,10.10.2.100,10.10.2.200,12h | ||
dhcp-option=tag:second, 3, 10.10.2.15 #default route won't be set if we give a static route | ||
dhcp-option=tag:second, 121, 10.10.1.0/24,10.10.2.1 | ||
dhcp-option=tag:first, 3, 10.10.1.15 #default route won't be set if we give a static route | ||
dhcp-option=tag:first, 121, 10.10.2.0/24,10.10.1.1 | ||
notify: Restart Dnsmasq | ||
|
||
- name: Set ipv4 forwarding on | ||
become: true | ||
ansible.posix.sysctl: | ||
name: net.ipv4.ip_forward | ||
value: '1' | ||
sysctl_set: yes | ||
state: present | ||
reload: yes | ||
|
||
handlers: | ||
- name: Restart Networking | ||
become: true | ||
ansible.builtin.service: | ||
name: networking | ||
state: restarted | ||
|
||
- name: Restart Dnsmasq | ||
become: true | ||
ansible.builtin.service: | ||
name: dnsmasq | ||
state: restarted |
Oops, something went wrong.