Skip to content

Instantly share code, notes, and snippets.

@elico
Created June 4, 2023 18:01
Show Gist options
  • Select an option

  • Save elico/b75fe3240dc5ac53d9aea3344a73e1cb to your computer and use it in GitHub Desktop.

Select an option

Save elico/b75fe3240dc5ac53d9aea3344a73e1cb to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Step 0: Update the OS
setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
dnf -y update
dnf -y install git wget vim bash-completion curl
# Reboot if neccesary
# Step 1: Install MariaDB Database Server
#bash -c "$(curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup)"
#dnf -y install MariaDB-server MariaDB-client MariaDB-backup
dnf module reset mariadb -y
dnf module enable mariadb:10.5 -y
dnf install -y mariadb-server
systemctl enable --now mariadb
# Step 2: Install git 2.x
dnf -y install epel-release
dnf -y install git
# Step 3: Install Ansible
dnf -y install ansible
# Step 4: Download Semaphore
VER=$(curl -s https://api.github.com/repos/ansible-semaphore/semaphore/releases/latest | grep tag_name | cut -d '"' -f 4 | sed 's/v//g')
wget https://github.com/ansible-semaphore/semaphore/releases/download/v${VER}/semaphore_${VER}_linux_amd64.rpm
dnf localinstall ./semaphore_${VER}_linux_amd64.rpm
# Step 5: Setup Semaphore
semaphore setup
# Step 6: Configure systemd unit for Semaphore
tee /etc/systemd/system/semaphore.service > /dev/null <<EOT
[Unit]
Description=Semaphore Ansible UI
Documentation=https://github.com/ansible-semaphore/semaphore
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/bin/semaphore server --config /etc/semaphore/config.json
SyslogIdentifier=semaphore
Restart=always
[Install]
WantedBy=multi-user.target
EOT
mkdir /etc/semaphore
cp -vf config.json /etc/semaphore/config.json
pkill semaphore
systemctl daemon-reload
systemctl restart semaphore
systemctl enable semaphore
# Step 7: Setup Nginx Proxy (Optional)
dnf -y install vim nginx
cat <<EOF >/etc/nginx/conf.d/semaphore.conf
upstream semaphore {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name semaphore.ngtech.home;
client_max_body_size 0;
chunked_transfer_encoding on;
location / {
proxy_pass http://semaphore/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_request_buffering off;
}
location /api/ws {
proxy_pass http://semaphore/api/ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Origin "";
}
}
EOF
nginx -t
systemctl restart nginx
systemctl enable nginx
# Step 8: Access Semaphore Web interface
echo "Installation completed. Access Semaphore Web interface using your server's IP address or domain name on port 3000 or 80."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment