Skip to content

Commit

Permalink
refactor of system_ldap role
Browse files Browse the repository at this point in the history
this role will depend on sssd_ad to bind to active directory
It will then be used to manage sftp accounts
  • Loading branch information
kayiwa committed Nov 8, 2024
1 parent d448dd5 commit 51ebad1
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 0 deletions.
38 changes: 38 additions & 0 deletions roles/lib_sftp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Role Name
=========

A brief description of the role goes here.

Requirements
------------

Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.

Role Variables
--------------

A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.

Dependencies
------------

A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.

Example Playbook
----------------

Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:

- hosts: servers
roles:
- { role: username.rolename, x: 42 }

License
-------

BSD

Author Information
------------------

An optional section for the role authors to include contact information, or a website (HTML is not allowed).
3 changes: 3 additions & 0 deletions roles/lib_sftp/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
# defaults file for sftp
almasftp_user: "almasftp"
2 changes: 2 additions & 0 deletions roles/lib_sftp/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# handlers file for sftp
18 changes: 18 additions & 0 deletions roles/lib_sftp/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
galaxy_info:
role_name: lib_sftp
company: Princeton University Library
description: Lib_SFTP
author: pulibrary

license: MIT

min_ansible_version: 2.9

platforms:
- name: Ubuntu
versions:
- jammy
dependencies:
- role: "common"
- role: "deploy_user"
15 changes: 15 additions & 0 deletions roles/lib_sftp/molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- name: Converge
hosts: all
vars:
- running_on_server: false
become: true
pre_tasks:
- name: Update cache
ansible.builtin.apt:
update_cache: true
cache_valid_time: 600
tasks:
- name: "Include lib_sftp"
ansible.builtin.include_role:
name: lib_sftp
22 changes: 22 additions & 0 deletions roles/lib_sftp/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
scenario:
name: default
driver:
name: docker
lint: |
set -e
yamllint .
ansible-lint
platforms:
- name: instance
image: "ghcr.io/pulibrary/pul_containers:jammy_multi"
command: "sleep infinity"
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
provisioner:
name: ansible
log: true
verifier:
name: ansible
20 changes: 20 additions & 0 deletions roles/lib_sftp/molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Check ruby package status
ansible.builtin.package:
name: "{{ item }}"
state: present
check_mode: true
register: pkg_status
loop:
- ruby-switch
- ruby2.6-dev
- ruby2.6

- name: Test for ruby packages
ansible.builtin.assert:
that:
- not pkg_status.changed
51 changes: 51 additions & 0 deletions roles/lib_sftp/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
# tasks file for lib_sftp
- name: Lib_sftp | create alma directory drop
ansible.builtin.file:
path: "{{ item }}"
state: directory
recurse: true
owner: "{{ almasftp_user }}"
group: "domain users@pu.win.princeton.edu"
mode: "0755"
loop:
- "/alma/bursar"
- "/alma/datasync_processing"
- "/alma/fund_adjustment"
- "/alma/invoice_status"
- "/alma/invoices"
- "/alma/people"
- "/alma/pod"
- "/alma/publishing"
- "/alma/recap"
- "/alma/scsb_renewals"

- name: Lib_sftp | grant {{ deploy_user }} access to alma directory
ansible.builtin.user:
name: "{{ deploy_user }}"
group: "domain users@pu.win.princeton.edu"
append: true

- name: Lib_sftp | create aspace directory drop
ansible.builtin.file:
path: /alma/aspace
state: directory
recurse: true
owner: "{{ aspaceftp_user }}"
group: "domain users@pu.win.princeton.edu"
mode: "0755"

- name: Lib_sftp | create local group for alma
ansible.builtin.group:
name: "domain users@pu.win.princeton.edu"
state: present

- name: Lib_sftp | create local user for alma
ansible.builtin.user:
name: almasftp
shell: /usr/bin/bash
group: "domain users@pu.win.princeton.edu"
password: "{{ almasftp_user_password }}"

- name: Lib_sftp | Flush handlers to be able to use SSSD authentication
ansible.builtin.meta: flush_handlers
2 changes: 2 additions & 0 deletions roles/lib_sftp/tests/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
localhost

5 changes: 5 additions & 0 deletions roles/lib_sftp/tests/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- sftp
2 changes: 2 additions & 0 deletions roles/lib_sftp/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# vars file for sftp

0 comments on commit 51ebad1

Please sign in to comment.