Skip to content
This repository has been archived by the owner on Nov 2, 2022. It is now read-only.

Add AIX Support #44

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2cb8475
Re-worked to use listen aliases + support for AIX
d-little Jun 21, 2019
54fb84f
Tested for aix 7.2 (probably ok for 7.2)
d-little Jun 21, 2019
2a78041
AIX root user is in the 'system' group
d-little Jun 21, 2019
3b19a9e
Added var 'samba_testparm'; default to testparm
d-little Jun 21, 2019
b2e4b52
Commented out redundant service starter
d-little Jun 21, 2019
3ad9ad1
init os_AIX.yml
d-little Jun 21, 2019
b4e6ab6
Update readme w/ testparm role variable
d-little Jun 24, 2019
b7b9ca1
Updated AIX dependencies (yum installed)
d-little Jun 24, 2019
57fc954
Removed 'name:' from AIX init.d commands
d-little Jun 24, 2019
d8b0b49
(git corruption on main; fixing)
d-little Jun 24, 2019
eb13be1
Absolute path for samba include files
d-little Jun 24, 2019
29b66ae
allow 'samba_passdb_backend' to be 'false'
d-little Jun 24, 2019
f046b3b
Fix samba includes to use samba_configuration_dir
d-little Jun 24, 2019
70c064a
rebase with new release on origin
d-little Jun 24, 2019
8b8483d
Added optional variable {{ samba_bin_dir }}
d-little Jun 24, 2019
8d1ee2c
fixed link
d-little Jun 24, 2019
192a500
Fixing up sbin dir
d-little Jul 5, 2019
961cccc
Clarify bin/sbin variable differences
d-little Jul 10, 2019
951073e
Clean up ansible_os_family status
d-little Jul 10, 2019
7aeccaa
Handle smbd restart for AIX and Linux in main task
d-little Jul 10, 2019
8e475cf
Add bin/sbin to defaults
d-little Jul 10, 2019
7420544
Remove unncessary slash
d-little Jul 10, 2019
fd1b6b9
Only start samba when it is not already running
d-little Jul 10, 2019
ecea556
Better AIX handler
d-little Jul 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ No specific requirements

| Variable | Default | Comments |
| :--- | :--- | :--- |
| `samba_apple_extensions` | no | When yes, enables support for Apple specific SMB extensions. Required for Time Machine support to work (see below) |
| `samba_create_varwww_symlinks` | false | When true, symlinks are created in web docroot to the shares. (`var/www/` or `/var/www/html` depending on platform) |
| `samba_apple_extensions` | no | When yes, enables support for Apple specific SMB extensions. Required for Time Machine support to work (see below) |
| `samba_bin_dir` | - | Directory where samba tools are stored. If not set will seach $PATH. |
| `samba_sbin_dir` | - | Directory where samba daemons are stored. If not set will seach $PATH. |
| `samba_create_varwww_symlinks` | false | When true, symlinks are created in web docroot to the shares. (`var/www/` or `/var/www/html` depending on platform) |
| `samba_cups_server` | localhost:631 | Value for the global option `cups server` (only needed when `samba_printer_type` is "cups") |
| `samba_domain_master` | true | When true, smbd enables WAN-wide browse list collation |
| `samba_global_include` | - | Samba-compatible configuration file with options to be loaded to [global] section (see below) |
Expand Down Expand Up @@ -203,6 +205,12 @@ The [test playbook](https://github.com/bertvv/ansible-role-samba/blob/docker-tes

## Dependencies

### AIX

This role assumes that the target AIX server is using the [AIX Toolbox for Linux](https://www.ibm.com/developerworks/aix/library/aix-toolbox) implementation of Yum with access to the `samba` and `samba-client` packages.

### Other

No dependencies.

## Example Playbook
Expand Down Expand Up @@ -239,6 +247,7 @@ Pull requests are also very welcome. Please create a topic branch for your propo
[Bert Van Vreckem](https://github.com/bertvv/) (maintainer),
[Birgit Croux](https://github.com/birgitcroux),
[DarkStar1973](https://github.com/DarkStar1973),
[David Little](https://github.com/d-little),
[George Hartzell](https://github.com/hartzell),
[Ian Young](https://github.com/iangreenleaf),
[Jonas Heinrich](https://github.com/onny),
Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ samba_local_master: 'yes'
samba_domain_master: 'yes'
samba_preferred_master: 'yes'
samba_mitigate_cve_2017_7494: true

samba_sbin_dir: ''
samba_bin_dir: ''
46 changes: 45 additions & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,51 @@
# File: roles/samba/handlers/main.yml
---
- name: Restart Samba services
- name: Restart Linux Samba services
vars:
linux_family:
- Archlinux
- Debian
- Gentoo
- RedHat
- Suse
service:
name: "{{ item }}"
state: restarted
with_items: "{{ samba_services }}"
when:
- ansible_os_family in linux_family
listen: "Restart Samba services"

- name: Restart AIX Samba services
command: "/etc/rc.d/init.d/{{ item }} restart"
with_items: "{{ samba_services }}"
when:
- ansible_os_family == "AIX"
listen: "Restart Samba services"

- name: Start Linux Samba services
vars:
linux_family:
- Archlinux
- Debian
- Gentoo
- RedHat
- Suse
service:
name: "{{ item }}"
state: started
enabled: true
with_items: "{{ samba_services }}"
when:
- ansible_os_family in linux_family
listen: "Start Samba services"

- name: Start AIX Samba services
shell: >
( /etc/rc.d/init.d/{{ item }} status| grep -q 'Samba {{ item }} daemon is not running.' ) && /etc/rc.d/init.d/{{ item }} start || true
register: status
changed_when: "' daemon... done.' in status.stdout"
with_items: "{{ samba_services }}"
when:
- ansible_os_family == 'AIX'
listen: "Start Samba services"
3 changes: 3 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ galaxy_info:
- name: ArchLinux
versions:
- all
- name: AIX
versions:
- 72
galaxy_tags:
- system
- networking
Expand Down
27 changes: 20 additions & 7 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
- name: Register Samba version
shell: >
set -o nounset -o pipefail -o errexit &&
smbd --version | sed 's/Version //'
{{ samba_sbin_dir | default('') }}smbd --version | sed 's/Version //'
args:
executable: /bin/bash
register: samba_version
Expand Down Expand Up @@ -53,11 +53,13 @@
tags: samba

- name: Create Samba shares root directory
vars:
group: "{{ 'system' if ansible_os_family == 'AIX' else 'root' }}"
file:
state: directory
path: "{{ samba_shares_root }}"
owner: root
group: root
group: "{{ group }}"
mode: '0755'
when: samba_shares|length > 0
tags: samba
Expand Down Expand Up @@ -93,7 +95,7 @@
template:
dest: "{{ samba_configuration }}"
src: smb.conf.j2
validate: 'testparm -s %s'
validate: "{{ samba_bin_dir | default('') }}testparm -s %s"
notify:
- Restart Samba services
tags: samba
Expand All @@ -102,7 +104,7 @@
template:
src: "{{ samba_global_include }}"
dest: "{{ samba_configuration_dir }}"
validate: 'testparm -s %s'
validate: "{{ samba_bin_dir | default('') }}testparm -s %s"
when: samba_global_include is defined
notify:
- Restart Samba services
Expand All @@ -112,7 +114,7 @@
template:
src: "{{ samba_homes_include }}"
dest: "{{ samba_configuration_dir }}"
validate: 'testparm -s %s'
validate: "{{ samba_bin_dir | default('') }}testparm -s %s"
when: samba_homes_include is defined
notify:
- Restart Samba services
Expand All @@ -122,7 +124,7 @@
template:
src: "{{ item.include_file }}"
dest: "{{ samba_configuration_dir }}"
validate: 'testparm -s %s'
validate: "{{ samba_bin_dir | default('') }}testparm -s %s"
when: item.include_file is defined
notify:
- Restart Samba services
Expand All @@ -145,11 +147,22 @@
enabled: true
with_items: "{{ samba_services }}"
tags: samba
when:
- ansible_os_family != 'AIX'

- name: Start Samba services (AIX)
shell: >
( /etc/rc.d/init.d/{{ item }} status| grep -q 'Samba {{ item }} daemon is not running.' ) && /etc/rc.d/init.d/{{ item }} start || true
register: status
changed_when: "' daemon... done.' in status.stdout"
with_items: "{{ samba_services }}"
when:
- ansible_os_family == 'AIX'

- name: Create Samba users if they don't exist yet
shell: >
set -o nounset -o pipefail -o errexit &&
(pdbedit --user={{ item.name }} 2>&1 > /dev/null) \
({{ samba_bin_dir|default('') }}pdbedit --user={{ item.name }} 2>&1 > /dev/null) \
|| (echo {{ item.password }}; echo {{ item.password }}) \
| smbpasswd -s -a {{ item.name }}
args:
Expand Down
4 changes: 3 additions & 1 deletion templates/smb.conf.j2
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@

# Authentication
security = {{ samba_security }}
{% if not samba_passdb_backend is sameas false %}
passdb backend = {{ samba_passdb_backend }}
{% endif %}
map to guest = {{ samba_map_to_guest }}
{% if samba_guest_account is defined %}
{% if samba_guest_account is defined %}
guest account = {{ samba_guest_account }}
{% endif %}
{% if samba_username_map is defined %}
Expand Down
23 changes: 23 additions & 0 deletions vars/os_AIX.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# roles/samba/vars/os_AIX.yml
---
# Assumes that the server has yum package manager set up:
# https://www.ibm.com/developerworks/community/blogs/aixpert/entry/AIX_and_yum_Get_those_Open_Source_apps_on_AIX_the_easy_way
samba_packages:
- samba
- samba-client

samba_configuration_dir: /etc/samba
samba_configuration: "{{ samba_configuration_dir }}/smb.conf"
samba_username_map_file: "{{ samba_configuration_dir }}/smbusers"

samba_bin_dir: /opt/freeware/bin/ # Where testperm lives
samba_sbin_dir: /opt/freeware/sbin/ # Where the daemons live

samba_services:
- smbd
- nmbd

samba_www_documentroot: []

# For information on Samba+AIX, a very old document:
# https://developer.ibm.com/articles/au-aix_samba