Linux
HOGENT toegepaste informatica
Thomas Parmentier, Andy Van Maele, Bert Van Vreckem
2024-2025
Opbouw in de opleiding:
Op je fysieke systeem!
winget install vagrant
brew install vagrant
apt install vagrant
(of dnf
)Of ga naar https://www.vagrantup.com/downloads
automation/
$ tree
.
├── LICENSE.md
├── provisioning
│ ├── common.sh
│ ├── db.sh
│ └── web.sh
├── README.md
├── Vagrantfile
└── vagrant-hosts.yml
1 directory, 7 files
Vagrantfile
: configuratiebestand van Vagrant
vagrant-hosts.yml
: overzicht VMs in de opstelling
provisioning/
: installatiescripts voor VMs$ vagrant status
Current machine states:
db not created (virtualbox)
web not created (virtualbox)
This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.
db
VM op$ vagrant up db
Bringing machine 'db' up with 'virtualbox' provider...
==> db: Importing base box 'bento/almalinux-9'...
==> db: Matching MAC address for NAT networking...
==> db: Checking if box 'bento/almalinux-9' version '202109.10.0' is up to date...
==> db: Setting the name of the VM: linux-2223-bertvv_db_1635848839364_33506
==> db: Clearing any previously set network interfaces...
==> db: Preparing network interfaces based on configuration...
db: Adapter 1: nat
db: Adapter 2: intnet
==> db: Forwarding ports...
db: 22 (guest) => 2222 (host) (adapter 1)
==> db: Running 'pre-boot' VM customizations...
==> db: Booting VM...
==> db: Waiting for machine to boot. This may take a few minutes...
db: SSH address: 127.0.0.1:2222
db: SSH username: vagrant
db: SSH auth method: private key
db:
db: Vagrant insecure key detected. Vagrant will automatically replace
db: this with a newly generated keypair for better security.
db:
db: Inserting generated public key within guest...
db: Removing insecure key from the guest if it's present...
db: Key inserted! Disconnecting and reconnecting using new SSH key...
==> db: Machine booted and ready!
==> db: Checking for guest additions in VM...
==> db: Setting hostname...
==> db: Configuring and enabling network interfaces...
==> db: Mounting shared folders...
db: /vagrant => /home/bert/Documents/Vakken/Linux/22-23/linux-2223-bertvv
==> db: Running provisioner: shell...
db: Running: /tmp/vagrant-shell20211102-9694-yq9qn5.sh
db: [LOG] === Starting common provisioning tasks ===
db: [LOG] Ensuring SELinux is activePermissivePermissivePermissive
db: [LOG] Installing useful packages
[...]
db: [LOG] Securing the database
db: [LOG] Creating database and user
db: [LOG] Creating database table and add some data
/vagrant
$ vagrant ssh db
This system is built by the Bento project by Chef Software
More information can be found at https://github.com/chef/bento
[vagrant@db ~]$ ip a show dev eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:1f:c4:a7 brd ff:ff:ff:ff:ff:ff
inet 192.168.76.3/24 brd 192.168.76.255 scope global noprefixroute eth1
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe1f:c4a7/64 scope link
valid_lft forever preferred_lft forever
[vagrant@db ~]$
Tip: bekijk het installatiescript provisioning/db.sh
Commando | Taak |
---|---|
vagrant status |
Overzicht omgeving |
vagrant up VM |
start VM op |
vagrant ssh VM |
inloggen op VM |
vagrant halt VM |
VM uitschakelen |
vagrant reload VM |
VM rebooten |
vagrant provision VM |
Installatie-script uitvoeren |
vagrant destroy VM |
VM vernietigen |
web
een webserverdb
toontvagrant up web
⇒ werkende
webserver!vagrant up web
en log inprovisioning/web.sh
in een
editorvagrant provision web
Herhaal 3-5 in kleine iteraties!
provision
is
voldoendevagrant destroy
vagrant destroy web; vagrant up web
dnf install
)useradd
)