diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index b1f5c67..ce58451 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout - uses: actions/checkout@v3.5.3 + uses: actions/checkout@v4.1.0 - name: Label actions uses: micnncim/action-label-syncer@v1.3.0 env: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index bd04a34..ea90e38 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout - uses: actions/checkout@v3.5.3 + uses: actions/checkout@v4.1.0 with: ref: ${{ github.head_ref }} - name: Get the version name from the tags @@ -19,7 +19,7 @@ jobs: run: | sed -Ei "s/^version: .*/version: ${{ env.RELEASE_VERSION }}/" galaxy.yml - name: Commit galaxy.yml - uses: stefanzweifel/git-auto-commit-action@v4.16.0 + uses: stefanzweifel/git-auto-commit-action@v5.0.0 with: branch: main commit_message: "Update galaxy.yml for ${{ env.RELEASE_VERSION }}" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 73f7e13..9b9fdc1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: scenario: ${{ steps.filter.outputs.changes }} steps: - name: Checkout - uses: actions/checkout@v3.5.3 + uses: actions/checkout@v4.1.0 - name: Detect changes uses: dorny/paths-filter@v2.11.1 id: filter @@ -51,11 +51,11 @@ jobs: scenario: ${{ fromJSON(needs.changes.outputs.scenario) }} steps: - name: Checkout - uses: actions/checkout@v3.5.3 + uses: actions/checkout@v4.1.0 with: path: ansible_collections/vladgh/samba - name: Molecule test - uses: gofrolist/molecule-action@v2.4.1 + uses: gofrolist/molecule-action@v2.5.3 with: molecule_command: test molecule_options: --debug diff --git a/README.md b/README.md index dc0dc63..8157c37 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ More info: <https://access.redhat.com/security/cve/cve-2017-7494> ## Using this collection -### Installing the Collection from Ansible Galaxy +### Install collection Install it with the Ansible Galaxy CLI: @@ -44,7 +44,16 @@ collections: - name: vladgh.samba ``` -Using the GitHub repository and specific branch or release: +Optionally, You can specify a version number: + +```yaml +--- +collections: + - name: vladgh.samba + version: ">=3.1.1" +``` + +You can also refer to a branch or to a git commit-ish object (commit, tag, branch or release) ```yaml collections: @@ -53,11 +62,19 @@ collections: type: git ``` -### Import Roles +For more information, see [Ansible using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) + +### Load role + +After the collection is installed you can include the `server` role. +You can define variables in a variety of places, such as in inventory, in playbooks, in reusable files, in roles, and at the command line. Ansible loads every possible variable it finds, then chooses the variable to apply based on [variable precedence rules](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#ansible-variable-precedence). +A complete overview of server role variables follows below. + +For more information, see [Using variables](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#where-to-set-variables). ```yaml --- -- name: Common +- name: Samba Server hosts: all become: true tasks: @@ -66,7 +83,9 @@ collections: name: vladgh.samba.server ``` -### Import Playbooks +### Import playbook + +Alternatively, you can directly import the existing playbook: ```yaml --- @@ -74,8 +93,6 @@ collections: ansible.builtin.import_playbook: vladgh.samba.server ``` -See [Ansible using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) for more details. - ## Server Role Variables | Variable | Default | Comments | @@ -107,6 +124,7 @@ See [Ansible using collections](https://docs.ansible.com/ansible/latest/user_gui | `samba_server_min_protocol` | - | Specify a minimum protocol version offered by the server. | | `samba_server_string` | `fileserver %m` | Comment string for the server. | | `samba_shares_root` | `/srv/shares` | Directories for the shares are created under this directory. | +| `samba_manage_directories` | `true` | Create the directories, and manage the permissions/ownership, of the shares root and the shares under it. | | `samba_shares` | `[]` | List of dicts containing share definitions. See below for details. | | `samba_username_map` | `[]` | Makes username map configurable. | | `samba_users` | `[]` | List of dicts defining users that can access shares. | diff --git a/roles/server/defaults/main.yml b/roles/server/defaults/main.yml index 0dd0e91..48e398d 100644 --- a/roles/server/defaults/main.yml +++ b/roles/server/defaults/main.yml @@ -14,6 +14,7 @@ samba_cups_server: 'localhost:631' samba_load_homes: false samba_create_varwww_symlinks: false samba_shares_root: '/srv/shares' +samba_manage_directories: true samba_shares: [] samba_users: [] diff --git a/roles/server/tasks/main.yml b/roles/server/tasks/main.yml index a22f225..d958b33 100644 --- a/roles/server/tasks/main.yml +++ b/roles/server/tasks/main.yml @@ -41,7 +41,8 @@ owner: root group: root mode: '0755' - when: samba_shares is defined and samba_shares | length > 0 + when: (samba_shares is defined and samba_shares | length > 0) and + ( samba_manage_directories is defined and samba_manage_directories ) tags: samba - name: Create share directories @@ -53,7 +54,8 @@ mode: "{{ item.directory_mode | default('0775') }}" setype: "{{ item.setype | default(omit) }}" loop: "{{ samba_shares }}" - when: samba_shares is defined and samba_shares | length > 0 + when: ( samba_shares is defined and samba_shares | length > 0 ) and + ( samba_manage_directories is defined and samba_manage_directories ) tags: samba - name: Ensure webserver document root exists