-
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.
fix: Little refactor and remove Alpine compatibility
- Loading branch information
Showing
1 changed file
with
33 additions
and
20 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 |
---|---|---|
@@ -1,54 +1,67 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
|
||
if [ -f /etc/debian_version ]; then | ||
export DEBIAN_FRONTEND=noninteractive | ||
apt-get -q update && apt-get -qy install ansible | ||
elif [ -f /etc/redhat-release ]; then | ||
dnf update -y && dnf install -y ansible-core | ||
dnf install -y ansible-core firewalld | ||
|
||
firewallrule() { | ||
firewall-cmd --permanent --zone=public --add-port=80/tcp && | ||
firewall-cmd --permanent --zone=public --add-port=443/tcp && | ||
systemctl start firewalld && \ | ||
systemctl enable firewalld && \ | ||
firewall-cmd --permanent --zone=public --add-port=80/tcp && \ | ||
firewall-cmd --permanent --zone=public --add-port=443/tcp && \ | ||
firewall-cmd --reload | ||
} | ||
} | ||
|
||
firewallrule | ||
|
||
ansible-galaxy collection install community.general | ||
elif [ -f /etc/alpine-release ]; then | ||
apk update && apk add ansible | ||
|
||
else | ||
echo "Unsuported Distro." | ||
fi | ||
|
||
tee -a requirements.yml <<'EOF' | ||
--- | ||
- src: dev-sec.ssh-hardening | ||
- src: nginxinc.nginx | ||
- src: geerlingguy.nginx | ||
EOF | ||
|
||
tee -a playbook.yml <<'EOF' | ||
--- | ||
- name: "Provision Nginx" | ||
hosts: localhost | ||
- hosts: localhost | ||
become: true | ||
vars: | ||
ssh_kex: | ||
- [email protected] | ||
- [email protected] | ||
- diffie-hellman-group-exchange-sha256 | ||
- [email protected] | ||
- [email protected] | ||
- diffie-hellman-group-exchange-sha256 | ||
ssh_server_ports: ['22'] | ||
ssh_permit_root_login: "without-password" | ||
ssh_use_pam: "true" | ||
sshd_authenticationmethods: "publickey" | ||
ssh_authorized_keys_file: ".ssh/authorized_keys" | ||
roles: | ||
- dev-sec.ssh-hardening | ||
- nginxinc.nginx | ||
become: true | ||
tasks: | ||
- name: Install Nginx | ||
include_role: | ||
name: geerlingguy.nginx | ||
- name: SSH Hardening | ||
include_role: | ||
name: dev-sec.ssh-hardening | ||
handlers: | ||
- name: start nginx | ||
service: | ||
name: nginx | ||
state: started | ||
EOF | ||
|
||
ansible-galaxy install -r requirements.yml | ||
ansible-playbook playbook.yml | ||
|
||
printf "<h1>Linode - It Works</h1>" >/usr/share/nginx/html/index.html | ||
if [ -f /etc/debian_version ]; then | ||
printf "<h1>DigitalOcean - It Works</h1>" > /var/www/html/index.nginx-debian.html | ||
elif [ -f /etc/redhat-release ]; then | ||
printf "<h1>DigitalOcean - It Works</h1>" > /usr/share/nginx/html/index.html | ||
else | ||
echo "Unsuported Distro." | ||
fi |