Compare commits

..

No commits in common. "main" and "2.1.0" have entirely different histories.
main ... 2.1.0

7 changed files with 93 additions and 85 deletions

View File

@ -9,58 +9,60 @@ parseable: true
use_default_rules: true
enable_list:
# Specific to use of command and shell modules
- command-instead-of-module
- command-instead-of-shell
- deprecated-command-syntax
- inline-env-var
- no-changed-when
- risky-shell-pipe
# Related to internal implementation of the linter
- internal-error
- load-failure
- parser-error
- syntax-check
# Indicate use of features that are removed from Ansible
- deprecated-bare-vars
- deprecated-command-syntax
- deprecated-local-action
- deprecated-module
- no-jinja-when
- role-name
# Related to code-style
- no-jinja-nesting
- no-tabs
- playbook-extension
- risky-octal
- var-spacing
- yaml
# Possible indication that consequent runs would produce different results
- git-latest
- hg-latest
- no-changed-when
- package-latest
# Anti-pattern detected, likely to cause undesired behavior
- command-instead-of-module
- command-instead-of-shell
- empty-string-compare
- inline-env-var
- literal-compare
- no-handler
- no-loop-var-prefix
- no-relative-paths
- unnamed-task
- var-naming
# Invalid metadata, likely related to galaxy, collections or roles
- meta-incorrect
- meta-no-tags
- meta-video-links
- role-name
- ignore-errors
- partial-become
- syntax-check
# External linter which will also produce its own rule codes.
- yaml
command-shell: # Specific to use of command and shell modules
- command-instead-of-module
- command-instead-of-shell
- deprecated-command-syntax
- inline-env-var
- no-changed-when
- risky-shell-pipe
core: # Related to internal implementation of the linter
- internal-error
- load-failure
- parser-error
- syntax-check
deprecations: # Indicate use of features that are removed from Ansible
- deprecated-bare-vars
- deprecated-command-syntax
- deprecated-local-action
- deprecated-module
- no-jinja-when
- role-name
formatting: # Related to code-style
- no-jinja-nesting
- no-tabs
- playbook-extension
- risky-octal
- var-spacing
- yaml
idempotency: # Possible indication that consequent runs would produce different results
- git-latest
- hg-latest
- no-changed-when
- package-latest
idiom: # Anti-pattern detected, likely to cause undesired behavior
- command-instead-of-module
- command-instead-of-shell
- empty-string-compare
- inline-env-var
- literal-compare
- no-handler
- no-loop-var-prefix
- no-relative-paths
- unnamed-task
- var-naming
metadata: # Invalid metadata, likely related to galaxy, collections or roles
- meta-incorrect
- meta-no-tags
- meta-video-links
- role-name
unpredictability:
- ignore-errors
- partial-become
unskippable:
- syntax-check
yaml: # External linter which will also produce its own rule codes.
- yaml
warn_list:
- experimental # all rules tagged as experimental
@ -69,6 +71,5 @@ warn_list:
skip_list:
- role-name # BUG
- name[casing]
verbosity: 1

View File

@ -1,10 +1,12 @@
---
name: Ansible Molecule
on: # yamllint disable-line rule:truthy
on: # yamllint disable-line rule:truthy
push:
tags_ignore:
- '*'
pull_request:
jobs:
setup:
name: Setup scenarios matrix
@ -25,6 +27,7 @@ jobs:
JSON="$JSON]"
echo "::set-output name=scenarios::$(echo $JSON)"
lint:
name: Lint
needs:
@ -35,16 +38,18 @@ jobs:
uses: actions/checkout@v3
with:
path: "${{ github.repository }}"
- name: Run ansible lint
uses: ansible/ansible-lint-action@main
- name: molecule
uses: robertdebock/molecule-action@4.0.9
with:
path: "."
command: lint
scenario: ${{ fromJson(needs.setup.outputs.scenarios)[0] }}
test:
name: Scenario "${{ matrix.scenario }}" on ${{ matrix.config.image }}:${{ matrix.config.tag }}
needs:
- lint
- setup
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
@ -55,28 +60,23 @@ jobs:
- name: "redhat"
image: "registry.access.redhat.com/ubi8/ubi"
tag: "latest"
- image: "debian"
tag: "12"
- image: "debian"
tag: "11"
- image: "debian"
tag: "10"
- image: "ubuntu"
tag: "22.04"
- image: ubuntu
tag: "24.04"
steps:
- name: checkout
uses: actions/checkout@v3
with:
path: "${{ github.repository }}"
- name: molecule
uses: gofrolist/molecule-action@v2
uses: robertdebock/molecule-action@4.0.9
with:
# molecule_options: --debug
molecule_command: test
molecule_args: --scenario-name ${{ matrix.scenario }} -d docker
molecule_working_dir: "${{ github.repository }}"
env:
image: ${{ matrix.config.image }}
tag: ${{ matrix.config.tag }}
scenario: ${{ matrix.scenario }}
env:
name: ${{ matrix.config.name }}

View File

@ -1,15 +1,24 @@
# Ansible role - motd
[![Maintainer](https://img.shields.io/badge/maintained%20by-claranet-e00000?style=flat-square)](https://www.claranet.fr/)
[![License](https://img.shields.io/github/license/claranet/ansible-role-motd?style=flat-square)](LICENSE)
[![Release](https://img.shields.io/github/v/release/claranet/ansible-role-motd?style=flat-square)](https://github.com/claranet/ansible-role-motd/releases)
[![Status](https://img.shields.io/github/workflow/status/claranet/ansible-role-motd/Ansible%20Molecule?style=flat-square&label=tests)](https://github.com/claranet/ansible-role-motd/actions?query=workflow%3A%22Ansible+Molecule%22)
[![Ansible version](https://img.shields.io/badge/ansible-%3E%3D2.9-black.svg?style=flat-square&logo=ansible)](https://github.com/ansible/ansible)
[![Ansible Galaxy](https://img.shields.io/badge/ansible-galaxy-black.svg?style=flat-square&logo=ansible)](https://galaxy.ansible.com/claranet/motd)
> :star: Star us on GitHub — it motivates us a lot!
Install and configure dynamic MOTD
This role uses [https://gitea.tips-of-mine.com/Tips-Of-Mine/motd](https://gitea.tips-of-mine.com/Tips-Of-Mine/motd) by default to get the MOTD
This role uses [https://github.com/claranet/motd](https://github.com/claranet/motd) by default to get the MOTD
```
System info:
Hostname·········: tips-of-mine_motd_ubuntu-20.04
Hostname·········: claranet_motd_ubuntu-20.04
Distro···········: Ubuntu 20.04.3 LTS
Kernel···········: Linux 5.10.47-linuxkit
Uptime···········: up 12 days, 23 hours, 18 minutes
Uptime···········: up 2 days, 23 hours, 18 minutes
Load·············: 1.33 (1m), 0.43 (5m), 0.20 (15m)
Processes········: 13 (root), 3 (user), 16 (total)
CPU··············: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz (4 vCPU)
@ -31,7 +40,7 @@ Ansible >= 2.10
## :zap: Installation
```bash
ansible-galaxy install tips-of-mine.motd
ansible-galaxy install claranet.motd
```
## :gear: Role variables
@ -39,7 +48,7 @@ ansible-galaxy install tips-of-mine.motd
Variable | Default value | Description
-----------------------------|------------------------------------------------------------------------|----------------------------------------------------------------
motd_disable_default_motd | true | Disable system default MOTD (/etc/motd)
motd_template | https://gitea.tips-of-mine.com/Tips-Of-Mine/motd/scripts/00-basic | Dynmaic MOTD template<br>Can be a URL or a local template
motd_template | https://raw.githubusercontent.com/claranet/motd/master/scripts/00-basic| Dynmaic MOTD template<br>Can be a URL or a local template
motd_template_prepend | "" | Prepend raw content to `motd_template`
motd_template_append | See [defaults/main.yml](defaults/main.yml) | Append raw content to `motd_template`
motd_template_username | "" | Used when `motd_template` is an URL
@ -51,7 +60,7 @@ motd_template_password | ""
---
- hosts: all
roles:
- role: tips-of-mine.motd
- role: claranet.motd
motd_template: "{{ playbook_dir }}/templates/dynmotd.j2"
```

View File

@ -1,6 +1,6 @@
---
motd_disable_default_motd: true
motd_template: https://gitea.tips-of-mine.com/Tips-Of-Mine/motd/master/scripts/00-basic
motd_template: https://raw.githubusercontent.com/claranet/motd/master/scripts/00-basic
motd_template_prepend: ""
motd_template_append: |

View File

@ -6,11 +6,11 @@
pre_tasks:
- name: "Update APT cache"
ansible.builtin.apt:
apt:
update_cache: true
when:
- ansible_pkg_mgr == "apt"
- name: Install sshd
ansible.builtin.package:
package:
name: openssh-server

View File

@ -1,14 +1,13 @@
---
dependency:
name: shell
command: python3 -m pip install pytest-testinfra
name: galaxy
driver:
name: docker
platforms:
# On "${name:-${image:-debian}", the last brace does not miss, it works like that...
# The env var should be used when the image variable refers to a full registry path like registry.access.redhat.com/ubi8/ubi
# The env var "name" should be used when the image variable refers to a full registry path like registry.access.redhat.com/ubi8/ubi
- name: claranet_motd_${name:-${image:-debian}-${tag:-latest}-${scenario:-default}
image: ${image:-debian}:${tag:-latest}
privileged: true
@ -27,14 +26,13 @@ provisioner:
name: ansible
env:
ANSIBLE_FORCE_COLOR: "true"
ANSIBLE_LOAD_CALLBACK_PLUGINS: "true"
ANSIBLE_STDOUT_CALLBACK: "ansible.posix.debug"
ANSIBLE_CALLBACKS_ENABLED: "ansible.posix.profile_tasks"
options:
v: true
verifier:
name: testinfra
lint:
name: flake8
options:
verbose: true
s: true

View File

@ -3,7 +3,7 @@
ansible.builtin.include_tasks: disable_default_motd.yml
when: motd_disable_default_motd|bool
- name: "Configure_motd | Apply template {{ motd_template + ' in ' + _motd_file_path }}"
- name: configure_motd | Apply template {{ motd_template }} on {{ _motd_file_path }}
ansible.builtin.copy:
content: "{{ motd_template_prepend + _motd_template_content + motd_template_append }}"
dest: "{{ _motd_file_path }}"
@ -13,7 +13,7 @@
tags:
- molecule-idempotence-notest
- name: Configure_motd | Add in pam pam_exec {{ _motd_file_path }}
- name: configure_motd | Add pam_exec {{ _motd_file_path }} in pam
ansible.builtin.lineinfile:
path: "{{ item }}"
line: session optional pam_exec.so type=open_session stdout {{ _motd_file_path }}