-
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.
added goslmailer install, uninstall, and role
- Loading branch information
1 parent
48549d1
commit dc5d2d6
Showing
7 changed files
with
225 additions
and
1 deletion.
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,3 +1,16 @@ | ||
## Nix | ||
|
||
To install the Nix package manager run the install_nix.yml playbook. | ||
|
||
To remove the Nix package manager run the uninstall_nix.yml playbook. | ||
Both playbooks are idempotent. If you get an error running the uninstall_nix.yml playbook rerun the playbook. | ||
|
||
Both playbooks are idempotent. If you get an error running the uninstall_nix.yml playbook rerun the playbook. | ||
|
||
## Goslmailer | ||
To install goslmailer run the goslmailer_install.yml and enter the slack_bot_token from the [slack bot app](https://app.slack.com/app-settings/T04PVJTPVCJ/A05AGQ7HNBX) (OAuth & Permissions -> OAuth Tokens for Your Workspace -> Bot User OAuth Token). Followed by the app password for the notification email ([email protected]). This is generated by the following steps: | ||
1. Enable 2fa for the account [https://myaccount.google.com/security](https://myaccount.google.com/security). Make sure you select the do-not-reply account on the login screen or change to it in the top right corner. | ||
1. Now go to: [https://myaccount.google.com/apppasswords](https://myaccount.google.com/apppasswords). Again ensure you are on the correct account. | ||
1. Press the "select app" dropdown and select "other". Then enter any name you like such as "CAIS Notifications". This will only be used here but should be recognizable. | ||
1. Press "Generate" in the bottom right and copy this password (Copy this into terminal window when prompted). | ||
|
||
To uninstall goslmailer run goslmailer_uninstall.yml. Note that this does not remove the MailProg entry from the slurm.conf. This won't cause problems but will be silently erroring in the slurmctld.log. So if you want to be clean you can remove that from the config. |
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,137 @@ | ||
- name: Download and unpack from github as well as get user prompt | ||
hosts: bastion | ||
become: true | ||
vars_prompt: | ||
- name: slack_bot_token | ||
prompt: "Enter the slack bot token" | ||
- name: app_password | ||
prompt: "Enter the app password for the email account" | ||
tasks: | ||
- name: Include a role dynamically | ||
include_role: | ||
name: goslmailer | ||
|
||
- name: Copy binaries | ||
copy: | ||
src: /tmp/goslmailer/goslmailer | ||
dest: /bin | ||
owner: slurm | ||
group: slurm | ||
mode: '0770' | ||
|
||
- copy: | ||
src: /tmp/goslmailer/gobler | ||
dest: /bin | ||
owner: slurm | ||
group: slurm | ||
mode: '0770' | ||
|
||
- name: Create slack directory | ||
file: | ||
path: /var/spool/slack | ||
state: directory | ||
owner: slurm | ||
group: slurm | ||
mode: '0770' | ||
|
||
- name: Copy Notification templates | ||
copy: | ||
src: "/tmp/goslmailer/notification_templates" | ||
dest: /etc/slurm/ | ||
mode: '0744' | ||
owner: slurm | ||
group: slurm | ||
|
||
- name: Copy goslmailer.conf | ||
copy: | ||
src: "/tmp/goslmailer/goslmailer.conf" | ||
dest: /etc/slurm/goslmailer.conf | ||
mode: '0600' | ||
owner: slurm | ||
group: slurm | ||
|
||
- name: Copy gobler.conf | ||
copy: | ||
src: "/tmp/goslmailer/gobler.conf" | ||
dest: /etc/slurm/gobler.conf | ||
mode: '0600' | ||
owner: slurm | ||
group: slurm | ||
|
||
- name: Copy gobler.service | ||
copy: | ||
src: "/tmp/goslmailer/gobler.service" | ||
dest: /etc/systemd/system/ | ||
mode: '0644' | ||
owner: root | ||
group: root | ||
|
||
- name: Reload systemd daemon | ||
systemd: | ||
daemon_reload: yes | ||
|
||
- name: Disable gobler service | ||
systemd: | ||
name: gobler | ||
enabled: false | ||
|
||
- name: Install mutt | ||
vars: | ||
package_name: | ||
- mutt | ||
include_role: | ||
name: safe_yum | ||
|
||
- name: Copy Muttrc.local | ||
copy: | ||
src: "/tmp/goslmailer/Muttrc.local" | ||
dest: /etc/Muttrc.local | ||
mode: '0600' | ||
|
||
- name: Restart postfix service | ||
systemd: | ||
name: postfix | ||
state: restarted | ||
enabled: yes | ||
|
||
- name: Create goslmailer.log | ||
file: | ||
path: /data/spool/goslmailer.log | ||
state: touch | ||
mode: '0600' | ||
owner: slurm | ||
group: slurm | ||
|
||
- name: Set ownership and permissions for spool | ||
file: | ||
path: "{{ item.path }}" | ||
state: directory | ||
mode: "{{ item.mode }}" | ||
owner: root | ||
group: root | ||
loop: | ||
- { path: '/var/spool/postfix', mode: '0755'} | ||
- { path: '/var/spool/mail', mode: '0755'} | ||
|
||
- name: Set ownership and permissions for Muttrc | ||
file: | ||
path: "{{ item.path }}" | ||
state: file | ||
mode: "{{ item.mode }}" | ||
owner: slurm | ||
group: slurm | ||
loop: | ||
- { path: '/etc/Muttrc', mode: '0600'} | ||
- { path: '/etc/Muttrc.local', mode: '0600'} | ||
|
||
- name: Edit config files | ||
replace: | ||
path: "{{ item.path }}" | ||
regexp: "{{ item.regex }}" | ||
replace: "{{ item.new }}" | ||
loop: | ||
- { path: '/etc/slurm/goslmailer.conf', regex: "\\$SLACK_BOT_TOKEN", new: "{{ slack_bot_token }}"} | ||
- { path: '/etc/slurm/gobler.conf', regex: "\\$SLACK_BOT_TOKEN", new: "{{ slack_bot_token }}"} | ||
- { path: '/etc/Muttrc.local', regex: "\\$EMAIL_ADDRESS", new: "[email protected]"} | ||
- { path: '/etc/Muttrc.local', regex: "\\$PLAIN_TEXT_NAME", new: "CAIS Notifications"} | ||
- { path: '/etc/Muttrc.local', regex: "\\$APP_PASSWORD", new: "{{ app_password }}"} |
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,54 @@ | ||
- name: Uninstall goslmailer | ||
hosts: bastion | ||
become: true | ||
tasks: | ||
- name: Remove goslmailer binary | ||
file: | ||
path: /bin/goslmailer | ||
state: absent | ||
|
||
- name: Remove gobler binary | ||
file: | ||
path: /bin/gobler | ||
state: absent | ||
|
||
- name: Remove slack directory | ||
file: | ||
path: /var/spool/slack | ||
state: absent | ||
|
||
- name: Remove notification_templates directory | ||
file: | ||
path: /etc/slurm/notification_templates | ||
state: absent | ||
|
||
- name: Remove goslmailer.log file | ||
file: | ||
path: /var/log/goslmailer.log | ||
state: absent | ||
|
||
- name: Remove goslmailer.conf file | ||
file: | ||
path: /etc/slurm/goslmailer.conf | ||
state: absent | ||
|
||
- name: Remove gobler.conf file | ||
file: | ||
path: /etc/slurm/gobler.conf | ||
state: absent | ||
|
||
- name: Stop gobler service | ||
systemd: | ||
name: gobler | ||
state: stopped | ||
enabled: false | ||
ignore_errors: True | ||
|
||
- name: Remove gobler.service file | ||
file: | ||
path: /etc/systemd/system/gobler.service | ||
state: absent | ||
|
||
- name: Reload systemd daemon | ||
systemd: | ||
daemon_reload: true |
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,2 @@ | ||
goslmailer_version: v2.7.1.1 | ||
download_checksum: sha512:9e48c639889c76278d4dd4874a5110c924fe2ea1784d1a11e74ef6a99371f6a8843fff376cc81a8b1fcf5fac335b19b5801fa9d373153f3378e4752c86cd3b2f |
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,16 @@ | ||
- name: Download and unpack files | ||
block: | ||
- name: Download zip | ||
get_url: | ||
url: "{{ download_path }}" | ||
dest: /tmp | ||
checksum: "{{ download_checksum }}" | ||
- name: Create temp directory | ||
file: | ||
path: /tmp/goslmailer | ||
state: directory | ||
- name: Extract installer files | ||
unarchive: | ||
src: /tmp/goslmailer-{{ goslmailer_version }}.zip | ||
remote_src: false | ||
dest: /tmp/goslmailer/ |
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 @@ | ||
download_path: "https://github.com/centerforaisafety/goslmailer/releases/download/{{ goslmailer_version }}/goslmailer-{{ goslmailer_version }}.zip" |
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