Compare commits

...

64 Commits
docs ... main

Author SHA1 Message Date
1f33cd00c9 [skip ci] automated docs update 2024-02-19 09:39:47 +00:00
76d86bcf9b
ci: migrate to woodpecker
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/notify Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/docs Pipeline was successful
2024-02-19 10:37:58 +01:00
5df6ca3348
[skip ci] fix drone-matrix template 2023-02-08 21:16:28 +01:00
4c996bf5fa
ci: switch to molecule v4
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-21 09:14:21 +01:00
dc617c6b91
ci: update python images to 3.10
All checks were successful
continuous-integration/drone/push Build is passing
2022-07-02 21:53:37 +02:00
a3c09437f8
chore: switch to main as default branch
All checks were successful
continuous-integration/drone/push Build is passing
2022-06-20 22:20:36 +02:00
3b4cecedc3
chore: add auto-generated _docs folder to gitignore file
All checks were successful
continuous-integration/drone/push Build is passing
2022-03-03 21:16:05 +01:00
e0bc8b64a8 feat: add test for Rocky Linux 8 (#1)
All checks were successful
continuous-integration/drone/push Build is passing
Co-authored-by: Robert Kaussow <xoxys@rknet.org>
Co-committed-by: Robert Kaussow <xoxys@rknet.org>
2022-01-26 21:01:55 +01:00
7e00724c9a
chore: end of the year maintenance [skip ci] 2021-12-21 10:45:44 +01:00
76d45b95ae
trigger ci run
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-21 23:41:56 +02:00
6043aa8352
ci: switch to drone-matrix plugin
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-21 22:36:58 +02:00
5705a65115
fix ci yapf command if no python files found
All checks were successful
continuous-integration/drone/push Build is passing
2021-06-08 00:25:51 +02:00
9a98e48ca6
fix ci yapf command if no python files found
All checks were successful
continuous-integration/drone/push Build is passing
2021-06-08 00:14:00 +02:00
b8263a05fa
ci: add python file checks to ci
All checks were successful
continuous-integration/drone/push Build is passing
2021-06-07 22:28:13 +02:00
9e13515ed1
chore: replace flake8 config file and add autoformatting 2021-06-07 22:14:32 +02:00
1689bca9ba
chore: update collection xoxys.generl to v2.1.1
All checks were successful
continuous-integration/drone/push Build is passing
2021-05-16 17:01:03 +02:00
f7ea140c59
chore: update collection xoxys.generl to v2.1.0
All checks were successful
continuous-integration/drone/push Build is passing
2021-05-16 16:06:23 +02:00
ccfb90d3a4
[skip ci] cleanup metadata 2021-04-23 12:12:08 +02:00
ecacfc5da2
[skip ci] update min_ansible_version to 2.10 2021-03-14 17:50:13 +01:00
1f818fef32
[skip ci] fix molecule instance config formatting 2021-03-14 16:24:21 +01:00
be1cb4e1ff
[skip ci] update copyright year 2021-03-14 15:14:58 +01:00
84d1b5eceb
fix broken link to ansible docs
All checks were successful
continuous-integration/drone/push Build is passing
2021-02-21 15:41:21 +01:00
4870438c44
fix: disable logs explicitly in molecule config
All checks were successful
continuous-integration/drone/push Build is passing
2021-02-04 22:42:34 +01:00
faf031258e
chore: bump ansible-later standards to v0.2
All checks were successful
continuous-integration/drone/push Build is passing
2021-02-04 21:32:26 +01:00
cd4fc64f9b
fix molecule requirements
All checks were successful
continuous-integration/drone/push Build is passing
2020-11-29 23:13:27 +01:00
0db5e66a10
switch to native filters instead of molecule internals
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-19 09:27:47 +02:00
199f8959aa
switch to native filters instead of molecule internals
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-19 09:06:58 +02:00
0988e79684
fix molecule destroy playbook
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-04 12:40:47 +02:00
f0d350f552
add option to attach volumes
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-03 17:12:31 +02:00
586ba5e451
[skip ci] fix heading 2020-10-03 13:39:42 +02:00
c9d74a9dda
move molecule tests to hcloud
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-02 09:32:16 +02:00
ecef66e701
trigger ci
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-01 19:52:01 +02:00
e608d6877a
cleanup readme
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-01 19:22:33 +02:00
dbf2ae95a1
update email
Some checks are pending
continuous-integration/drone/push Build is running
2020-10-01 17:12:37 +02:00
9d6e54f261
remove docs downstream trigger as this doesnt work well for mass updates
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-01 16:47:38 +02:00
c42c659bfb
fix formatting
Some checks reported errors
continuous-integration/drone/push Build was killed
2020-10-01 11:20:27 +02:00
7aeb90c305
[skip ci] fix refs to migrated repos 2020-09-27 23:24:17 +02:00
a765985312
[skip ci] update collections 2020-09-04 23:17:10 +02:00
93a977c4de
migrate dependencies to collections
All checks were successful
continuous-integration/drone/push Build is passing
2020-08-19 18:39:06 +02:00
5a21a49808 fix link to the license file
All checks were successful
continuous-integration/drone/push Build is passing
2020-06-04 15:15:58 +02:00
916de510eb fix downstream repo
All checks were successful
continuous-integration/drone/push Build is passing
2020-05-25 23:01:26 +02:00
9e28b0c45d add ansible env vars to molecule
All checks were successful
continuous-integration/drone/push Build is passing
2020-03-21 19:02:56 +01:00
3b51bb3976 [SKIP CI] remove custom flake8 format 2020-03-21 17:57:52 +01:00
5d3178f74e add flake8 config
All checks were successful
continuous-integration/drone/push Build is passing
2020-03-21 16:33:21 +01:00
95e038107b cleanup meta file
Some checks failed
continuous-integration/drone/push Build is failing
2020-03-21 14:36:05 +01:00
ce0f254a56 cleanup drone config 2020-03-21 14:35:14 +01:00
1b71a86204 fix moldecule linting section 2020-03-21 14:12:15 +01:00
2102efe92d upgrade to molecule v3
All checks were successful
continuous-integration/drone/push Build is passing
2020-02-21 00:46:35 +01:00
c66bc093ac [SKIP CI] update readme 2020-02-17 22:49:06 +01:00
5d53d4a17c [SKIP CI] fix license formatting 2020-02-01 18:03:09 +01:00
82db81e3d6 cleanup documentation
All checks were successful
continuous-integration/drone/push Build is passing
2020-01-31 11:23:20 +01:00
7389e74847 update meta file 2020-01-30 23:26:11 +01:00
249161b930 update license file 2020-01-30 23:19:52 +01:00
81488dc548 cleanup readme 2020-01-30 23:07:48 +01:00
6dce72d18d remove block storage attachment
All checks were successful
continuous-integration/drone/push Build is passing
2020-01-27 13:47:04 +01:00
eb4759a7d6 update var description
All checks were successful
continuous-integration/drone/push Build is passing
2020-01-26 16:21:00 +01:00
cac1ab20b2 fix centos 8 testing
All checks were successful
continuous-integration/drone/push Build is passing
2020-01-26 16:02:02 +01:00
7b847ef503 add centos 8 testing
Some checks failed
continuous-integration/drone/push Build is failing
2020-01-26 15:55:10 +01:00
bc69b5d35c fix wording
All checks were successful
continuous-integration/drone/push Build is passing
2020-01-26 15:35:29 +01:00
b4806df97a cleanup badges
All checks were successful
continuous-integration/drone/push Build is passing
2020-01-26 15:29:37 +01:00
5d5f883230 fix gitea badge logo color
All checks were successful
continuous-integration/drone/push Build is passing
2020-01-26 01:14:09 +01:00
3cf774f3f6 change drone build badge
All checks were successful
continuous-integration/drone/push Build is passing
2020-01-26 01:06:18 +01:00
b42d0dc279 change badge order
All checks were successful
continuous-integration/drone/push Build is passing
2020-01-26 00:47:52 +01:00
3fd2e1ba9d initial commit
All checks were successful
continuous-integration/drone/push Build is passing
2020-01-26 00:09:27 +01:00
20 changed files with 436 additions and 0 deletions

11
.gitignore vendored Normal file
View File

@ -0,0 +1,11 @@
# ---> Ansible
*.retry
plugins
library
# ---> Python
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

15
.later.yml Normal file
View File

@ -0,0 +1,15 @@
---
ansible:
custom_modules:
- iptables_raw
- openssl_pkcs12
- proxmox_kvm
- ucr
- corenetworks_dns
- corenetworks_token
rules:
exclude_files:
- "LICENSE*"
- "**/*.md"
- "**/*.ini"

7
.markdownlint.yml Normal file
View File

@ -0,0 +1,7 @@
---
default: True
MD013: False
MD041: False
MD024: False
MD004:
style: dash

1
.prettierignore Normal file
View File

@ -0,0 +1 @@
LICENSE

47
.woodpecker/docs.yaml Normal file
View File

@ -0,0 +1,47 @@
---
when:
- event: [pull_request]
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
steps:
- name: generate
image: quay.io/thegeeklab/ansible-doctor
environment:
ANSIBLE_DOCTOR_EXCLUDE_FILES: molecule/
ANSIBLE_DOCTOR_FORCE_OVERWRITE: "true"
ANSIBLE_DOCTOR_LOG_LEVEL: INFO
ANSIBLE_DOCTOR_ROLE_NAME: ${CI_REPO_NAME}
ANSIBLE_DOCTOR_TEMPLATE: readme
- name: format
image: quay.io/thegeeklab/alpine-tools
commands:
- prettier -w README.md
- name: diff
image: quay.io/thegeeklab/alpine-tools
commands:
- git diff --color=always README.md
- name: publish
image: quay.io/thegeeklab/wp-git-action
settings:
action:
- commit
- push
author_email: ci-bot@rknet.org
author_name: ci-bot
branch: main
message: "[skip ci] automated docs update"
netrc_machine: gitea.rknet.org
netrc_password:
from_secret: gitea_token
when:
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
depends_on:
- test

30
.woodpecker/lint.yaml Normal file
View File

@ -0,0 +1,30 @@
---
when:
- event: [pull_request, tag]
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
steps:
- name: ansible-later
image: quay.io/thegeeklab/ansible-later:4
commands:
- ansible-later
environment:
FORCE_COLOR: "1"
- name: python-format
image: docker.io/python:3.12
commands:
- pip install -qq ruff
- ruff format --check --diff .
environment:
PY_COLORS: "1"
- name: python-lint
image: docker.io/python:3.12
commands:
- pip install -qq ruff
- ruff .
environment:
PY_COLORS: "1"

26
.woodpecker/notify.yml Normal file
View File

@ -0,0 +1,26 @@
---
when:
- event: [tag]
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
runs_on: [success, failure]
steps:
- name: matrix
image: quay.io/thegeeklab/wp-matrix
settings:
homeserver:
from_secret: matrix_homeserver
password:
from_secret: matrix_password
roomid:
from_secret: matrix_roomid
username:
from_secret: matrix_username
when:
- status: [success, failure]
depends_on:
- docs

25
.woodpecker/test.yaml Normal file
View File

@ -0,0 +1,25 @@
---
when:
- event: [pull_request, tag]
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
variables:
- &molecule_base
image: quay.io/thegeeklab/molecule:6
group: molecule
secrets:
- source: molecule_hcloud_token
target: HCLOUD_TOKEN
environment:
PY_COLORS: "1"
steps:
- name: molecule-default
<<: *molecule_base
commands:
- molecule test -s default
depends_on:
- lint

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 Robert Kaussow <mail@thegeeklab.de>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

78
README.md Normal file
View File

@ -0,0 +1,78 @@
# xoxys.smb
[![Build Status](https://ci.rknet.org/api/badges/ansible/xoxys.smb/status.svg)](https://ci.rknet.org/repos/ansible/xoxys.smb)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](https://gitea.rknet.org/ansible/xoxys.smb/src/branch/main/LICENSE)
Mount a list of Samba shares.
## Table of content
- [Requirements](#requirements)
- [Default Variables](#default-variables)
- [smb_packages](#smb_packages)
- [smb_shares](#smb_shares)
- [Dependencies](#dependencies)
- [License](#license)
- [Author](#author)
---
## Requirements
- Minimum Ansible version: `2.10`
## Default Variables
### smb_packages
#### Default value
```YAML
smb_packages:
- cifs-utils
```
### smb_shares
Mount defined samba shares. You can specify samba credentials with the
`username` and `password` parameter. Given credentials will be used in a secrets file
and saved to `/root/.smbcredentials/<name>` instead of the direct use in `/etc/fstab`.
If secrets are defined for a list item, the secrest file will also be passed automatically
to `mountopts`.
The `state` parameter is related to the possible state values of Ansibles
[mount](https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html) module.
#### Default value
```YAML
smb_shares: []
```
#### Example usage
```YAML
smb_shares:
- name: multimedia
source: //share.example.com/media
username: myuser
password: secure
mountpoint: /media/data
mountopts:
- acl
- uid=1000
- gid=1000
state: mounted
```
## Dependencies
None.
## License
MIT
## Author
[Robert Kaussow](https://gitea.rknet.org/xoxys)

29
defaults/main.yml Normal file
View File

@ -0,0 +1,29 @@
---
smb_packages:
- cifs-utils
# @var smb_shares:description: >
# Mount defined samba shares. You can specify samba credentials with the
# `username` and `password` parameter. Given credentials will be used in a secrets file
# and saved to `/root/.smbcredentials/<name>` instead of the direct use in `/etc/fstab`.
# If secrets are defined for a list item, the secrest file will also be passed automatically
# to `mountopts`.
#
# The `state` parameter is related to the possible state values of Ansibles
# [mount](https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html) module.
# @end
# @var smb_shares:example: >
# smb_shares:
# - name: multimedia
# source: //share.example.com/media
# username: myuser
# password: secure
# mountpoint: /media/data
# mountopts:
# - acl
# - uid=1000
# - gid=1000
# state: mounted
# @end
smb_shares: []

26
meta/main.yml Normal file
View File

@ -0,0 +1,26 @@
---
galaxy_info:
# @meta author:value: [Robert Kaussow](https://gitea.rknet.org/xoxys)
author: Robert Kaussow <mail@thegeeklab.de>
namespace: xoxys
role_name: smb
# @meta description: >
# [![Build Status](https://ci.rknet.org/api/badges/ansible/xoxys.smb/status.svg)](https://ci.rknet.org/repos/ansible/xoxys.smb)
# [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](https://gitea.rknet.org/ansible/xoxys.smb/src/branch/main/LICENSE)
#
# Mount a list of Samba shares.
# @end
description: Mount a list of Samba shares
license: MIT
min_ansible_version: "2.10"
platforms:
- name: EL
versions:
- "9"
galaxy_tags:
- storage
- smb
- samba
dependencies: []
collections:
- community.general

View File

@ -0,0 +1,15 @@
---
- name: Converge
hosts: all
vars:
smb_shares:
- name: multimedia
source: //share.example.com/media
username: myuser
password: secure
mountpoint: /media/data
mountopts:
- acl
state: present
roles:
- role: xoxys.smb

View File

@ -0,0 +1,17 @@
---
driver:
name: molecule_hetznercloud
dependency:
name: galaxy
options:
role-file: molecule/requirements.yml
requirements-file: molecule/requirements.yml
platforms:
- name: "rocky9-smb"
server_type: "cx11"
image: "rocky-9"
provisioner:
name: ansible
log: False
verifier:
name: testinfra

View File

@ -0,0 +1,11 @@
---
- name: Prepare
hosts: all
gather_facts: False
tasks:
- name: Bootstrap Python for Ansible
ansible.builtin.raw: |
command -v python3 python ||
((test -e /usr/bin/apt && (apt -y update && apt install -y python-minimal)) ||
echo "Warning: Python not boostrapped due to unknown platform.")
changed_when: False

View File

@ -0,0 +1,19 @@
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ["MOLECULE_INVENTORY_FILE"]
).get_hosts("all")
def test_smb_in_fstab(host):
fstab = host.file("/etc/fstab")
assert fstab.contains("//share.example.com/media")
def test_smb_credentials(host):
credentials = host.file("/root/.smbcredentials/multimedia")
assert credentials.exists
assert credentials.contains("username=myuser")
assert credentials.contains("password=secure")

View File

@ -0,0 +1,4 @@
---
collections: []
roles: []

17
pyproject.toml Normal file
View File

@ -0,0 +1,17 @@
[tool.ruff]
exclude = [".git", "__pycache__"]
line-length = 99
indent-width = 4
[tool.ruff.lint]
ignore = ["W191", "E111", "E114", "E117", "S101", "S105"]
select = ["F", "E", "I", "W", "S"]
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
line-ending = "lf"
[tool.pytest.ini_options]
filterwarnings = ["ignore::FutureWarning", "ignore::DeprecationWarning"]

35
tasks/main.yml Normal file
View File

@ -0,0 +1,35 @@
---
- name: Install requirements
ansible.builtin.package:
name: "{{ item }}"
state: present
loop: "{{ smb_packages }}"
- name: Ensure credentials folder exist
ansible.builtin.file:
path: /root/.smbcredentials
owner: root
group: root
mode: "0600"
state: directory
- name: Create secrets file
ansible.builtin.template:
src: "smbcredentials.j2"
dest: "/root/.smbcredentials/{{ item.name }}"
mode: "0600"
loop: "{{ smb_shares }}"
loop_control:
label: "/root/.smbcredentials/{{ item.name }}"
when: item.password is defined and item.password
- name: Mount volume
ansible.posix.mount:
path: "{{ item.mountpoint }}"
src: "{{ item.source }}"
fstype: "cifs"
opts: "{{ ((item.mountopts | default([])) if not (item.password is defined and item.password) else ((item.mountopts | default([])) + ['credentials=/root/.smbcredentials/' + item.name])) | join(',') }}"
state: "{{ item.state | default('mounted') }}"
loop: "{{ smb_shares }}"
loop_control:
label: "mount: {{ item.source }} {{ item.mountpoint }} cifs {% if item.mountopts is defined %}{{ item.mountopts | join(',') }}{% endif %}"

View File

@ -0,0 +1,2 @@
username={{ item.username }}
password={{ item.password }}