This guide installs a Jekyll build environment with Ruby/Bundler and Nginx for static hosting.
It supports Debian 10 to latest stable, Ubuntu LTS, and RHEL 9+ compatible systems.
- name: Install Jekyll
hosts: jekyll
become: true
vars:
jekyll_root: /opt/jekyll-site
tasks:
- name: Install dependencies on Debian/Ubuntu
apt:
name:
- ruby-full
- build-essential
- zlib1g-dev
- nginx
- curl
- git
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install dependencies on RHEL family
dnf:
name:
- ruby
- ruby-devel
- gcc
- gcc-c++
- make
- nginx
- curl
- git
state: present
when: ansible_os_family == "RedHat"
- name: Ensure Nginx is enabled and started
service:
name: nginx
state: started
enabled: true
- name: Install Jekyll and Bundler gems globally
gem:
name: "{{ item }}"
state: present
user_install: false
loop:
- bundler
- jekyll
- name: Create Jekyll project root
file:
path: "{{ jekyll_root }}"
state: directory
mode: "0755"
- name: Check whether Gemfile exists
stat:
path: "{{ jekyll_root }}/Gemfile"
register: jekyll_gemfile
- name: Install Jekyll dependencies if Gemfile exists
command: bundle install
args:
chdir: "{{ jekyll_root }}"
when: jekyll_gemfile.stat.exists
- name: Build Jekyll site if Gemfile exists
command: bundle exec jekyll build
args:
chdir: "{{ jekyll_root }}"
when: jekyll_gemfile.stat.exists
_site/, which is then served by Nginx.We develop tailored automation solutions for:
Let’s discuss your requirements: office@linux-server-admin.com | Contact