Skip to content

Commit

Permalink
change systemd init.d file
Browse files Browse the repository at this point in the history
  • Loading branch information
kayiwa committed Jan 10, 2025
1 parent 90e7dd1 commit f2cba66
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 60 deletions.
86 changes: 32 additions & 54 deletions roles/ezproxy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,16 @@
loop:
- "files/ezproxy.bin"


- name: Ezproxy | install dependencies for 64bit
ansible.builtin.apt:
name: ["lib32ncurses6", "lib32z1"]
name: "{{ item }}"
state: present

- name: Ezproxy | copy ezproxy config.txt
ansible.builtin.template:
src: "config.txt.j2"
dest: "/var/local/ezproxy/config.txt"
owner: root
group: root
mode: "0644"
changed_when: false
when:
- running_on_server
loop:
- libc6
- libstdc++6
- lsof
- lib32ncurses
- lib32z1

- name: Ezproxy | install missing file replacements
ansible.builtin.command: /var/local/ezproxy/ezproxy -m
Expand All @@ -42,6 +36,13 @@
when:
- running_on_server

- name: Ezproxy | install ezproxy startup script (requires root)
ansible.builtin.command: /var/local/ezproxy/ezproxy -si
become: true
become_user: "root"
changed_when: false
when: running_on_server

- name: Ezproxy | run command with WSKey
ansible.builtin.command: /var/local/ezproxy/ezproxy -k "{{ oclc_wskey }}"
become: true
Expand All @@ -56,35 +57,14 @@
owner: "{{ deploy_user }}"
mode: "0755"

- name: Ezproxy | install snapd
- name: Ezproxy | install certbot
ansible.builtin.apt:
name: snapd
name: certbot
state: present
update_cache: true

- name: Ezproxy | install snap core
community.general.snap:
name: core
when: running_on_server

- name: Ezproxy | install snap certbot
community.general.snap:
name: certbot
classic: true
when: running_on_server

- name: Ezproxy | create certbot link
ansible.builtin.file:
src: "/snap/bin/certbot"
dest: "/usr/bin/certbot"
state: link
group: root
owner: root
when: running_on_server

- name: Ezproxy | update acme certificates for {{ domain_name }}
ansible.builtin.command: /usr/bin/certbot certonly --standalone --non-interactive --agree-tos --email [email protected] --server https://acme.sectigo.com/v2/InCommonRSAOV --eab-kid {{ vault_acme_eab_kid }} --eab-hmac-key {{ vault_acme_eab_hmac_key }} --domain {{ domain_name }}.princeton.edu --cert-name {{ domain_place_name }}
notify: restart ezproxy
when: running_on_server

- name: Ezproxy | Creates a log directory for ezproxy
Expand All @@ -99,7 +79,7 @@
- name: Ezproxy | rotate the logs
ansible.builtin.template:
src: ezproxy.j2
dest: '/etc/logrotate.d/ezproxy'
dest: "/etc/logrotate.d/ezproxy"
mode: "0644"

- name: Ezproxy | Create app directory
Expand All @@ -120,7 +100,7 @@
owner: "{{ deploy_user }}"
group: "{{ deploy_user }}"

- name: Ezproxy | Allow {{ deploy_user }} to restart ezproxy
- name: Ezproxy | Allow ability to restart ezproxy for {{ deploy_user }}
ansible.builtin.lineinfile:
dest: "/etc/sudoers"
state: "present"
Expand Down Expand Up @@ -164,14 +144,6 @@
when:
- running_on_server

- name: Ezproxy | install ezproxy startup script (requires root)
ansible.builtin.command: /var/local/ezproxy/ezproxy -si
become: true
become_user: 'root'
changed_when: false
when: running_on_server


- name: Ezproxy | add shib config user
ansible.builtin.template:
src: "shibuser.txt.j2"
Expand All @@ -180,31 +152,37 @@
owner: root
group: root


- name: Ezproxy | copy a systemd service
ansible.builtin.template:
src: "ezproxy.service.j2"
dest: /var/local/ezproxy/ezproxy.service
dest: /lib/systemd/system/ezproxy.service
owner: root
group: root
mode: a+x
changed_when: false
when:
- running_on_server

- name: Ezproxy | reload systemd to recognize new service
ansible.builtin.systemd:
daemon_reload: true
when:
- running_on_server
notify: reload ezproxy

- name: Ezproxy | symbolic link
ansible.builtin.file:
src: /var/local/ezproxy/ezproxy.service
dest: /lib/systemd/system/ezproxy.service
- name: Ezproxy | copy ezproxy config.txt
ansible.builtin.template:
src: "config.txt.j2"
dest: "/var/local/ezproxy/config.txt"
owner: root
group: root
state: link
mode: "0644"
changed_when: false
when:
- running_on_server

- name: Ezproxy | start ezproxy
ansible.builtin.service:
name: ezproxy
state: started
state: enabled
when: running_on_server
9 changes: 3 additions & 6 deletions roles/ezproxy/templates/ezproxy.service.j2
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# Ansible
# {{ ansible_managed | comment }}
[Unit]
Description=EZProxy
Documentation=https://help.oclc.org/Library_Management/EZproxy
PartOf=Network.target
After=local-fs.target nss-lookup.target network-online.target
After=network.target local-fs.target nss-lookup.target network-online.target

[Service]
Type=forking
WorkingDirectory=/var/local/ezproxy
Type=simple
ExecStart=/var/local/ezproxy/ezproxy start
ExecStop=/var/local/ezproxy/ezproxy stop
ExecReload=/var/local/ezproxy/ezproxy restart
KillMode=none
Restart=on-failure
RestartSec=3

Expand Down

0 comments on commit f2cba66

Please sign in to comment.