-
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.
Merge pull request #2 from punktDe/linux-support
Add Linux support
- Loading branch information
Showing
17 changed files
with
292 additions
and
41 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,10 @@ | ||
--- | ||
skip_list: | ||
- 'risky-shell-pipe' | ||
- 'role-name' | ||
|
||
warn_list: | ||
- package-latest | ||
- unnamed-task | ||
- command-instead-of-shell | ||
- no-handler |
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,47 @@ | ||
--- | ||
name: Test | ||
run-name: Run molecule tests on the role | ||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies. | ||
run: pip install yamllint ansible-lint ansible | ||
|
||
- name: Run ansible-lint | ||
run: "ansible-lint" | ||
|
||
molecule: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies. | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install ansible docker molecule molecule-plugins | ||
sudo apt install rsync | ||
- name: Install Galaxy dependencies. | ||
run: ansible-galaxy collection install community.docker community.mysql | ||
|
||
- name: Run molecule | ||
run: "molecule test" |
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 @@ | ||
--- | ||
repos: | ||
- repo: https://github.com/ansible/ansible-lint.git | ||
rev: v6.17.2 | ||
hooks: | ||
- id: ansible-lint |
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,33 @@ | ||
--- | ||
# Based on ansible-lint config | ||
extends: default | ||
|
||
rules: | ||
braces: | ||
max-spaces-inside: 1 | ||
level: error | ||
brackets: | ||
max-spaces-inside: 1 | ||
level: error | ||
colons: | ||
max-spaces-after: -1 | ||
level: error | ||
commas: | ||
max-spaces-after: -1 | ||
level: error | ||
comments: disable | ||
comments-indentation: disable | ||
document-start: disable | ||
empty-lines: | ||
max: 3 | ||
level: error | ||
hyphens: | ||
level: error | ||
indentation: disable | ||
key-duplicates: enable | ||
line-length: disable | ||
new-line-at-end-of-file: disable | ||
new-lines: | ||
type: unix | ||
trailing-spaces: disable | ||
truthy: disable |
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,9 +1,20 @@ | ||
--- | ||
varnish: | ||
service_name: >- | ||
{%- if ansible_system == 'Linux' -%} | ||
varnish | ||
{%- else -%} | ||
varnishd | ||
{%- endif -%} | ||
prefix: | ||
config: /usr/local/etc/varnish | ||
config: >- | ||
{%- if ansible_system == 'Linux' -%} | ||
/etc/varnish | ||
{%- else -%} | ||
/usr/local/etc/varnish | ||
{%- endif -%} | ||
bind_addr: "localhost:8080" | ||
#logformat: '%h "%{X-Forwarded-For}i" %u %t "%r" %s %b "%{Referer}i" "%{User-agent}i" "%{Varnish:time_firstbyte}x" %{Varnish:handling}x "%{Content-Type}o" "%{Cookie}i"' | ||
logformat: > | ||
{"time": %{"%FT%T%z"}t, "remote_addr": "%h","remote_user": "%u","x_forwarded_for": "%{X-Forwarded-For}i","x_real_ip": "%{X-Real-IP}i","x_request_id": "%{X-Request-ID}i","hit_miss": "%{Varnish:hitmiss}x","body_bytes_sent": "%b","request_time": "%{Varnish:time_firstbyte}x","status": "%s","content_type": "%{Content-Type}o","request": "%r","host": "%{host}i","request_method": "%m","time_first_byte": "%{Varnish:time_firstbyte}x","handling": "%{Varnish:handling}x","http_referrer": "%{Referrer}i","http_user_agent": "%{User-agent}i"} | ||
storage: malloc,512M | ||
storage: malloc,512M |
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,26 +1,26 @@ | ||
--- | ||
- name: Start Varnish | ||
service: | ||
name: varnishd | ||
ansible.builtin.service: | ||
name: "{{ varnish.service_name }}" | ||
state: started | ||
register: varnishd_service_result | ||
notify: Start Varnishncsa | ||
|
||
- name: Restart Varnish | ||
service: | ||
name: varnishd | ||
ansible.builtin.service: | ||
name: "{{ varnish.service_name }}" | ||
state: restarted | ||
when: not (varnishd_service_result is defined and varnishd_service_result.changed) | ||
notify: Restart Varnishncsa | ||
|
||
- name: Start Varnishncsa | ||
service: | ||
ansible.builtin.service: | ||
name: varnishncsa | ||
state: started | ||
register: varnishncsa_service_result | ||
|
||
- name: Restart Varnishncsa | ||
service: | ||
ansible.builtin.service: | ||
name: varnishncsa | ||
state: restarted | ||
when: not (varnishncsa_service_result is defined and varnishncsa_service_result.changed) |
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,10 @@ | ||
--- | ||
dependencies: [] | ||
|
||
galaxy_info: | ||
author: "Punkt.de" | ||
license: "MIT" | ||
description: "Varnish role for Proserver" | ||
role_name: "proserver_varnish" | ||
namespace: "punktde" | ||
min_ansible_version: "2.15" |
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 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
tasks: | ||
- name: "Include ansible-proserver-varnish" | ||
ansible.builtin.include_role: | ||
name: "ansible-proserver-varnish" |
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,27 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: docker | ||
platforms: | ||
- name: instance | ||
image: geerlingguy/docker-ubuntu2204-ansible | ||
command: /lib/systemd/systemd | ||
pre_build_image: true | ||
privileged: true | ||
cgroupns_mode: host | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:rw | ||
provisioner: | ||
name: ansible | ||
playbooks: | ||
converge: ${MOLECULE_PLAYBOOK:-converge.yml} | ||
verifier: | ||
name: ansible | ||
scenario: | ||
name: default | ||
test_sequence: | ||
- destroy | ||
- create | ||
- converge | ||
- verify |
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,26 @@ | ||
--- | ||
# This is an example playbook to execute Ansible tests. | ||
|
||
- name: Verify | ||
hosts: all | ||
gather_facts: false | ||
tasks: | ||
- name: Check Varnish status | ||
register: varnish_systemd | ||
changed_when: no | ||
ansible.builtin.command: | ||
cmd: systemctl status varnish | ||
|
||
- name: Check Varnishncsa status | ||
register: varnishncsa_systemd | ||
changed_when: no | ||
ansible.builtin.command: | ||
cmd: systemctl status varnishncsa | ||
|
||
- name: Debug | ||
ansible.builtin.debug: | ||
var: varnish_systemd.stdout | ||
|
||
- name: Debug | ||
ansible.builtin.debug: | ||
var: varnishncsa_systemd.stdout |
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 @@ | ||
- name: Install varnish | ||
notify: | ||
- Start Varnish | ||
- Start Varnishncsa | ||
ansible.builtin.apt: | ||
name: varnish | ||
update_cache: yes |
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,2 +1,9 @@ | ||
--- | ||
- import_tasks: service.yaml | ||
- ansible.builtin.include_tasks: install.yaml | ||
Check warning on line 2 in tasks/main.yaml GitHub Actions / lintname[missing]
|
||
when: "ansible_system == 'Linux'" | ||
|
||
- ansible.builtin.include_tasks: service-Debian.yaml | ||
Check warning on line 5 in tasks/main.yaml GitHub Actions / lintname[missing]
|
||
when: "ansible_os_family == 'Debian'" | ||
|
||
- ansible.builtin.include_tasks: service-FreeBSD.yaml | ||
Check warning on line 8 in tasks/main.yaml GitHub Actions / lintname[missing]
|
||
when: "ansible_os_family == 'FreeBSD'" |
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,48 @@ | ||
--- | ||
- name: Create systemd override folders | ||
ansible.builtin.file: | ||
path: /etc/systemd/system/{{ item }}.service.d | ||
state: directory | ||
owner: root | ||
mode: "0755" | ||
loop: | ||
- varnish | ||
- varnishncsa | ||
|
||
- name: Configure Varnish service override | ||
notify: | ||
- Restart Varnish | ||
ansible.builtin.template: | ||
dest: /etc/systemd/system/varnish.service.d/override.conf | ||
src: varnish.service.d/override.conf | ||
mode: "0644" | ||
owner: root | ||
|
||
- name: Template a Varnishncsa wrapper script | ||
notify: | ||
- Restart Varnishncsa | ||
ansible.builtin.copy: | ||
content: | | ||
#! /bin/sh | ||
/usr/bin/varnishncsa -a -w /var/log/varnish/varnishncsa.log -D -P /run/varnishncsa/varnishncsa.pid -F {{ varnish.logformat | quote }} | ||
dest: "/usr/local/bin/varnishncsa_systemd_wrapper" | ||
mode: "0755" | ||
owner: "root" | ||
|
||
- name: Configure Varnishncsa service override | ||
notify: | ||
- Restart Varnishncsa | ||
ansible.builtin.template: | ||
dest: /etc/systemd/system/varnishncsa.service.d/override.conf | ||
src: varnishncsa.service.d/override.conf | ||
mode: "0644" | ||
owner: root | ||
|
||
- name: Enable services | ||
loop: | ||
- "{{ varnish.service_name }}" | ||
- varnishncsa | ||
ansible.builtin.systemd: | ||
daemon_reload: yes | ||
name: "{{ item }}" | ||
enabled: yes |
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,31 @@ | ||
--- | ||
- name: Configure Varnish service | ||
ansible.builtin.lineinfile: | ||
path: "{{ item.rc_conf }}" | ||
regexp: "{{ item.regexp }}" | ||
line: "{{ item.line }}" | ||
create: yes | ||
mode: "0755" | ||
owner: "root" | ||
with_items: | ||
- rc_conf: /usr/local/etc/rc.conf.d/varnishd | ||
regexp: "^varnishd_listen=" | ||
line: > | ||
varnishd_listen={{ varnish.bind_addr | trim | quote }} | ||
- rc_conf: /usr/local/etc/rc.conf.d/varnishd | ||
regexp: "^varnishd_storage=" | ||
line: > | ||
varnishd_storage="{{ varnish.storage | trim | quote }}" | ||
- rc_conf: /usr/local/etc/rc.conf.d/varnishncsa | ||
regexp: "^varnishncsa_logformat=" | ||
line: > | ||
varnishncsa_logformat={{ varnish.logformat | trim | replace('"', '\"') | quote }} | ||
notify: | ||
- Restart Varnish | ||
|
||
- name: Enable service | ||
notify: | ||
- Start Varnish | ||
ansible.builtin.service: | ||
name: "{{ varnish.service_name }}" | ||
enabled: yes |
This file was deleted.
Oops, something went wrong.
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,10 @@ | ||
[Service] | ||
ExecStart= | ||
ExecStart=/usr/sbin/varnishd \ | ||
-j unix,user=vcache \ | ||
-F \ | ||
-a :6081 \ | ||
-T {{ varnish.bind_addr | trim }} \ | ||
-f /etc/varnish/default.vcl \ | ||
-S /etc/varnish/secret \ | ||
-s {{ varnish.storage | trim }} |
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 @@ | ||
[Service] | ||
ExecStart= | ||
ExecStart=/usr/local/bin/varnishncsa_systemd_wrapper |