-
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.
a working config! serves static files out of ~/public, downloads and …
…extracts hugo, clones zephnet repository
- Loading branch information
zazzyzeph
committed
Sep 14, 2024
1 parent
699fc95
commit 6b9c90d
Showing
10 changed files
with
237 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vagrant |
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 @@ | ||
# -*- 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 = "ubuntu/jammy64" | ||
|
||
# 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: 8090, 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" | ||
|
||
# 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 "~/zndb", "/home/vagrant/zephnet" | ||
|
||
# Disable the default share of the current code directory. Doing this | ||
# provides improved isolation between the vagrant box and your host | ||
# by making sure your Vagrantfile isn't accessible to the vagrant box. | ||
# If you use this you may want to enable additional shared subfolders as | ||
# shown above. | ||
# config.vm.synced_folder ".", "/vagrant", disabled: true | ||
|
||
# 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.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 | ||
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the | ||
# documentation for more information about their specific syntax and use. | ||
# config.vm.provision "shell", inline: <<-SHELL | ||
# apt-get update | ||
# apt-get install -y apache2 | ||
# SHELL | ||
config.vm.provision "ansible" do |ansible| | ||
ansible.verbose = "v" | ||
ansible.playbook = "site.yml" | ||
ansible.groups = { | ||
"webservers" => ['default'] | ||
} | ||
end | ||
end |
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,13 @@ | ||
webserver_static_sites: | ||
- name: zephnet.biz | ||
root: /home/vagrant/hugo | ||
public: /home/vagrant/public | ||
repository: https://github.com/zazzyzeph/zephnet | ||
|
||
# - name: site2.example.com | ||
# root: /usr/share/nginx/site2.example.com | ||
# repository: https://github.com/acritelli/example-static-site.git | ||
|
||
# - name: site3.example.com | ||
# root: /usr/share/nginx/site3.example.com | ||
# repository: https://github.com/acritelli/example-static-site.git |
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,35 @@ | ||
user vagrant; | ||
worker_processes auto; | ||
error_log /var/log/nginx/error.log; | ||
pid /run/nginx.pid; | ||
|
||
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. | ||
include /usr/share/nginx/modules/*.conf; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
root /home/vagrant/public; | ||
|
||
access_log /var/log/nginx/access.log main; | ||
|
||
server_tokens off; | ||
sendfile on; | ||
tcp_nopush on; | ||
tcp_nodelay on; | ||
keepalive_timeout 65; | ||
types_hash_max_size 2048; | ||
|
||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
# Load modular configuration files from the /etc/nginx/conf.d directory. | ||
# See http://nginx.org/en/docs/ngx_core_module.html#include | ||
# for more information. | ||
include /etc/nginx/conf.d/*.conf; | ||
} |
13 changes: 13 additions & 0 deletions
13
roles/webserver/files/usr/share/nginx/site1.example.com/index.html
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,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Site 1</title> | ||
</head> | ||
<body> | ||
<h1>Welcome to Site 1</h1> | ||
<p> | ||
did this work? | ||
<p> | ||
</body> | ||
</html> |
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,6 @@ | ||
--- | ||
# handlers file for webserver | ||
- name: Reload NGINX | ||
service: | ||
name: nginx | ||
state: reloaded |
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,59 @@ | ||
--- | ||
- name: Install packages | ||
become: yes | ||
package: | ||
update_cache: true | ||
name: "{{ webserver_packages }}" | ||
state: latest | ||
|
||
- name: Turn off apache | ||
become: yes | ||
ansible.builtin.service: | ||
name: apache2 | ||
state: stopped | ||
|
||
- name: Add base NGINX configuration file | ||
become: yes | ||
copy: | ||
dest: /etc/nginx/nginx.conf | ||
src: etc/nginx/nginx.conf | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
notify: Reload NGINX | ||
|
||
# Uncomment below to use file-based deployment instead of git-based deployment | ||
# Included only as an example | ||
# - name: Copy site contents | ||
# copy: | ||
# dest: "{{ item.root }}/" | ||
# src: "usr/share/nginx/{{ item.name }}/" | ||
# owner: root | ||
# group: root | ||
# mode: 0755 | ||
# with_items: "{{ webserver_static_sites }}" | ||
|
||
- name: Clone git repositories | ||
git: | ||
repo: "{{ item.repository}}" | ||
dest: "{{ item.root }}" | ||
force: yes | ||
with_items: "{{ webserver_static_sites }}" | ||
|
||
- name: Add static site config files | ||
become: yes | ||
template: | ||
src: etc/nginx/conf.d/site.conf.j2 | ||
dest: "/etc/nginx/conf.d/{{ item.name }}.conf" | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
with_items: "{{ webserver_static_sites }}" | ||
notify: Reload NGINX | ||
|
||
- name: Download/Extract Hugo | ||
unarchive: | ||
src: https://github.com/gohugoio/hugo/releases/download/v0.134.2/hugo_0.134.2_linux-arm64.tar.gz | ||
dest: "{{ item.root }}" | ||
remote_src: true | ||
with_items: "{{ webserver_static_sites }}" |
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,16 @@ | ||
server { | ||
listen 80; | ||
listen [::]:80; | ||
|
||
server_name {{ item.name }}; | ||
root {{ item.public }}; | ||
index index.html | ||
server_tokens off; | ||
charset utf-8; | ||
|
||
location / { | ||
# First attempt to serve request as file, then | ||
# as directory, then fall back to displaying a 404. | ||
try_files $uri $uri/ =404; | ||
} | ||
} |
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,7 @@ | ||
--- | ||
# vars file for webserver | ||
webserver_packages: | ||
- nginx | ||
- git | ||
- php | ||
- trimage |
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,3 @@ | ||
- hosts: webservers | ||
roles: | ||
- webserver |