mirror of
https://github.com/iiab/iiab.git
synced 2025-02-14 20:22:08 +00:00
Samba role standardized/modularized, for runrole etc
This commit is contained in:
parent
0715af5d18
commit
0484ea38f1
4 changed files with 83 additions and 65 deletions
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
2. Without PHP available via FastCGI, any function at all for PHP-based applications validates NGINX.
|
2. Without PHP available via FastCGI, any function at all for PHP-based applications validates NGINX.
|
||||||
|
|
||||||
3. Current state of IIAB App/Service migrations as of 2020-09-12:
|
3. Current state of IIAB App/Service migrations as of 2020-09-21:
|
||||||
|
|
||||||
1. These support "Native" NGINX but ***NOT*** Apache
|
1. These support "Native" NGINX but ***NOT*** Apache
|
||||||
* Admin Console
|
* Admin Console
|
||||||
|
@ -47,6 +47,7 @@
|
||||||
* openvpn
|
* openvpn
|
||||||
* pbx [*, requires Apache for now, as in Section iii.]
|
* pbx [*, requires Apache for now, as in Section iii.]
|
||||||
* phpmyadmin [*, requires Apache for now, as in Section iii.]
|
* phpmyadmin [*, requires Apache for now, as in Section iii.]
|
||||||
|
* samba
|
||||||
* transmission [*]
|
* transmission [*]
|
||||||
|
|
||||||
[*] The 6 above starred roles could use improvement, as of 2020-09-12.
|
[*] The 6 above starred roles could use improvement, as of 2020-09-21.
|
||||||
|
|
19
roles/samba/tasks/enable-or-disable.yml
Normal file
19
roles/samba/tasks/enable-or-disable.yml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
- name: Enable & Start Samba service ({{ smb_service }}) and NetBIOS name service ({{ nmb_service }}) if samba_enabled
|
||||||
|
systemd:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: started
|
||||||
|
enabled: yes
|
||||||
|
when: samba_enabled | bool
|
||||||
|
with_items:
|
||||||
|
- "{{ smb_service }}"
|
||||||
|
- "{{ nmb_service }}"
|
||||||
|
|
||||||
|
- name: Disable & Stop Samba service ({{ smb_service }}) and NetBIOS name service ({{ nmb_service }}) if not samba_enabled
|
||||||
|
systemd:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: stopped
|
||||||
|
enabled: no
|
||||||
|
when: not samba_enabled
|
||||||
|
with_items:
|
||||||
|
- "{{ smb_service }}"
|
||||||
|
- "{{ nmb_service }}"
|
41
roles/samba/tasks/install.yml
Normal file
41
roles/samba/tasks/install.yml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
- name: "Create smb user: {{ smbuser }}"
|
||||||
|
user:
|
||||||
|
name: "{{ smbuser }}"
|
||||||
|
shell: /sbin/nologin
|
||||||
|
password: "{{ smbpassword }}"
|
||||||
|
|
||||||
|
- name: "Create public folder: {{ shared_dir }}"
|
||||||
|
file:
|
||||||
|
path: "{{ shared_dir }}"
|
||||||
|
owner: "{{ smbuser }}"
|
||||||
|
group: "{{ smbuser }}"
|
||||||
|
mode: '0777'
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
# Install and configure samba server (requires ports 137, 138, 139, 445 open).
|
||||||
|
- name: "Install 4 packages: samba, samba-client, samba-common, cifs-client"
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- samba
|
||||||
|
- samba-client
|
||||||
|
- samba-common
|
||||||
|
- cifs-utils
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Install /etc/samba/smb.conf from template
|
||||||
|
template:
|
||||||
|
src: smb.conf.j2
|
||||||
|
dest: /etc/samba/smb.conf
|
||||||
|
|
||||||
|
|
||||||
|
# RECORD Samba AS INSTALLED
|
||||||
|
|
||||||
|
- name: "Set 'samba_installed: True'"
|
||||||
|
set_fact:
|
||||||
|
samba_installed: True
|
||||||
|
|
||||||
|
- name: "Add 'samba_installed: True' to {{ iiab_state_file }}"
|
||||||
|
lineinfile:
|
||||||
|
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
|
||||||
|
regexp: '^samba_installed'
|
||||||
|
line: 'samba_installed: True'
|
|
@ -1,73 +1,30 @@
|
||||||
- name: "Create smb user: {{ smbuser }}"
|
# "How do i fail a task in Ansible if the variable contains a boolean value?
|
||||||
user:
|
# I want to perform input validation for Ansible playbooks"
|
||||||
name: "{{ smbuser }}"
|
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
|
||||||
shell: /sbin/nologin
|
|
||||||
password: "{{ smbpassword }}"
|
|
||||||
|
|
||||||
- name: "Create public folder: {{ shared_dir }}"
|
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
|
||||||
file:
|
# to re-check whether vars are defined here. As Ansible vars cannot be unset:
|
||||||
path: "{{ shared_dir }}"
|
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
|
||||||
owner: "{{ smbuser }}"
|
|
||||||
group: "{{ smbuser }}"
|
|
||||||
mode: '0777'
|
|
||||||
state: directory
|
|
||||||
|
|
||||||
# Install and configure samba server (requires ports 137, 138, 139, 445 open).
|
- name: Assert that "samba_install is sameas true" (boolean not string etc)
|
||||||
- name: "Install 4 packages: samba, samba-client, samba-common, cifs-client"
|
assert:
|
||||||
package:
|
that: samba_install is sameas true
|
||||||
name:
|
fail_msg: "PLEASE SET 'samba_install: True' e.g. IN: /etc/iiab/local_vars.yml"
|
||||||
- samba
|
quiet: yes
|
||||||
- samba-client
|
|
||||||
- samba-common
|
|
||||||
- cifs-utils
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Install /etc/samba/smb.conf from template
|
- name: Assert that "samba_enabled | type_debug == 'bool'" (boolean not string etc)
|
||||||
template:
|
assert:
|
||||||
src: smb.conf.j2
|
that: samba_enabled | type_debug == 'bool'
|
||||||
dest: /etc/samba/smb.conf
|
fail_msg: "PLEASE GIVE VARIABLE 'samba_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
|
||||||
|
quiet: yes
|
||||||
|
|
||||||
|
|
||||||
# RECORD Samba AS INSTALLED
|
- name: Install Samba if 'samba_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
|
||||||
|
include_tasks: install.yml
|
||||||
- name: "Set 'samba_installed: True'"
|
when: samba_installed is undefined
|
||||||
set_fact:
|
|
||||||
samba_installed: True
|
|
||||||
|
|
||||||
- name: "Add 'samba_installed: True' to {{ iiab_state_file }}"
|
|
||||||
lineinfile:
|
|
||||||
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
|
|
||||||
regexp: '^samba_installed'
|
|
||||||
line: 'samba_installed: True'
|
|
||||||
|
|
||||||
|
|
||||||
- name: Enable & Start Samba systemd service ({{ smb_service }}) if samba_enabled
|
- include_tasks: enable-or-disable.yml
|
||||||
service:
|
|
||||||
name: "{{ smb_service }}"
|
|
||||||
state: started
|
|
||||||
enabled: yes
|
|
||||||
when: samba_enabled | bool
|
|
||||||
|
|
||||||
- name: Enable & Start NetBIOS name service ({{ nmb_service }}) if samba_enabled
|
|
||||||
service:
|
|
||||||
name: "{{ nmb_service }}"
|
|
||||||
state: started
|
|
||||||
enabled: yes
|
|
||||||
when: samba_enabled | bool
|
|
||||||
|
|
||||||
- name: Disable & Stop Samba systemd service ({{ smb_service }}) if not samba_enabled
|
|
||||||
systemd:
|
|
||||||
name: "{{ smb_service }}"
|
|
||||||
state: stopped
|
|
||||||
enabled: no
|
|
||||||
when: not samba_enabled
|
|
||||||
|
|
||||||
- name: Disable & Stop NetBIOS name service ({{ nmb_service }}) if not samba_enabled
|
|
||||||
systemd:
|
|
||||||
name: "{{ nmb_service }}"
|
|
||||||
state: stopped
|
|
||||||
enabled: no
|
|
||||||
when: not samba_enabled
|
|
||||||
|
|
||||||
|
|
||||||
- name: Add 'samba' variable values to {{ iiab_ini_file }}
|
- name: Add 'samba' variable values to {{ iiab_ini_file }}
|
||||||
|
|
Loading…
Reference in a new issue