-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVagrantfile
More file actions
57 lines (51 loc) · 2.55 KB
/
Copy pathVagrantfile
File metadata and controls
57 lines (51 loc) · 2.55 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
Vagrant.configure("2") do |config|
# Specify the RHEL 9 box
config.vm.box = "generic/rocky9" # Change if using another provider
# Set up the VM
config.vm.hostname = "rocky9-vm"
config.vm.network "private_network", type: "dhcp"
config.vm.network "forwarded_port", guest: 8000, host: 8000
# Customize VM resources
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
vb.cpus = 2
end
# Enable SSH
config.ssh.insert_key = false
# Provisioning (Optional: Install packages)
config.vm.provision "shell", inline: <<-SHELL
sudo dnf update -y
sudo dnf install -y ansible-core
sudo dnf install -y ansible
sudo dnf install -y python3-jmespath
sudo dnf install -y unzip
SHELL
config.vm.provision "shell", inline: <<-SHELL
sudo mkdir -p /fs/u02/apps_ux /fs/u02/apps_data /fs/u02/sw_ux
sudo touch /fs/u02/apps_ux/range:8000-8080
sudo chmod -R 775 /fs/u02
sudo ln -s /fs/u02/apps_data /apps_data
sudo ln -s /fs/u02/apps_ux /apps_ux
sudo ln -s /fs/u02/sw_ux /sw_ux
sudo groupadd -g 778 wwwadm
sudo useradd -u 778 -g 778 -c "apache user" -m -d /fs/u02/apps_ux/wwwadm -s /sbin/nologin wwwadm
sudo useradd -u 779 -g 778 -c "apache service" -m -d /fs/u02/apps_ux/wwwsvr -s /sbin/nologin wwwsvr
sudo chown wwwadm:wwwadm /fs/u02 /fs/u02/apps_ux /fs/u02/apps_data /fs/u02/sw_ux
sudo -i echo "umask 022" >> /apps_ux/wwwadm/.bashrc
sudo -i echo "umask 022" >> /apps_ux/wwwsvr/.bashrc
# https://forums.rockylinux.org/t/running-a-user-level-services-in-rocky-9/11880/4
sudo -i echo "export XDG_RUNTIME_DIR=/run/user/$(id -u)" >> /apps_ux/wwwsvr/.bashrc
sudo sed -i -- 's/PasswordAuthentication no/#PasswordAuthentication no/g' /etc/ssh/sshd_config
sudo sed -i -- 's/#PasswordAuthentication yes/PasswordAuthentication yes/g' /etc/ssh/sshd_config
sudo systemctl restart sshd
sudo -i echo "vagrant ALL=(wwwadm) NOPASSWD: ALL" >> /etc/sudoers
sudo -i echo "vagrant ALL=(wwwsvr) NOPASSWD: ALL" >> /etc/sudoers
sudo loginctl enable-linger wwwsvr
sudo loginctl user-status wwwsvr || echo "Lingering enabled, systemd user session will start on demand."
sudo mkdir -p /fs/u02/apps_ux/wwwsvr/.config/systemd/user
sudo chown wwwsvr:wwwadm /fs/u02/apps_ux/wwwsvr/.config /fs/u02/apps_ux/wwwsvr/.config/systemd /fs/u02/apps_ux/wwwsvr/.config/systemd/user
sudo chmod 775 /fs/u02/apps_ux/wwwsvr/.config /fs/u02/apps_ux/wwwsvr/.config/systemd /fs/u02/apps_ux/wwwsvr/.config/systemd/user
sudo chmod 755 /fs/u02/apps_ux/wwwsvr
sudo timedatectl set-timezone America/Vancouver
SHELL
end