update molecule scenarios
This commit is contained in:
parent
eb57d613dc
commit
8382c9f3f3
@ -2,6 +2,7 @@
|
|||||||
exclude_paths:
|
exclude_paths:
|
||||||
- molecule/
|
- molecule/
|
||||||
- .pre-commit-config.yaml
|
- .pre-commit-config.yaml
|
||||||
|
- .github/
|
||||||
|
|
||||||
parseable: true
|
parseable: true
|
||||||
|
|
||||||
|
50
.github/workflows/molecule.yml
vendored
50
.github/workflows/molecule.yml
vendored
@ -8,43 +8,75 @@ on: # yamllint disable-line rule:truthy
|
|||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
setup:
|
||||||
|
name: Setup scenarios matrix
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
outputs:
|
||||||
|
scenarios: ${{ steps.matrix.outputs.scenarios }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- id: matrix
|
||||||
|
run: |
|
||||||
|
JSON="["
|
||||||
|
|
||||||
|
for s in $(find molecule -mindepth 1 -maxdepth 1 -type d -exec basename "{}" \;); do
|
||||||
|
JSON="${JSON}\"${s}\","
|
||||||
|
done
|
||||||
|
|
||||||
|
JSON="${JSON%?}"
|
||||||
|
JSON="$JSON]"
|
||||||
|
|
||||||
|
echo "::set-output name=scenarios::$(echo $JSON)"
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-20.04
|
name: Lint
|
||||||
|
needs:
|
||||||
|
- setup
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
path: "${{ github.repository }}"
|
path: "${{ github.repository }}"
|
||||||
- name: molecule
|
- name: molecule
|
||||||
uses: robertdebock/molecule-action@2.6.17
|
uses: robertdebock/molecule-action@4.0.9
|
||||||
with:
|
with:
|
||||||
command: lint
|
command: lint
|
||||||
|
scenario: ${{ fromJson(needs.setup.outputs.scenarios)[0] }}
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
name: Scenario "${{ matrix.scenario }}" on ${{ matrix.config.image }}:${{ matrix.config.tag }}
|
||||||
needs:
|
needs:
|
||||||
- lint
|
- lint
|
||||||
runs-on: ubuntu-20.04
|
- setup
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
scenario: ${{ fromJson(needs.setup.outputs.scenarios) }}
|
||||||
config:
|
config:
|
||||||
- image: "amazonlinux"
|
- image: "amazonlinux"
|
||||||
tag: "latest"
|
tag: "latest"
|
||||||
- image: "fedora"
|
- name: "redhat"
|
||||||
tag: "28"
|
image: "registry.access.redhat.com/ubi8/ubi"
|
||||||
|
tag: "latest"
|
||||||
- image: "debian"
|
- image: "debian"
|
||||||
tag: "11"
|
tag: "11"
|
||||||
- image: "debian"
|
- image: "debian"
|
||||||
tag: "10"
|
tag: "10"
|
||||||
- image: "ubuntu"
|
- image: "ubuntu"
|
||||||
tag: "20.04"
|
tag: "22.04"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
path: "${{ github.repository }}"
|
path: "${{ github.repository }}"
|
||||||
- name: molecule
|
- name: molecule
|
||||||
uses: robertdebock/molecule-action@2.6.17
|
uses: robertdebock/molecule-action@4.0.9
|
||||||
with:
|
with:
|
||||||
image: ${{ matrix.config.image }}
|
image: ${{ matrix.config.image }}
|
||||||
tag: ${{ matrix.config.tag }}
|
tag: ${{ matrix.config.tag }}
|
||||||
|
scenario: ${{ matrix.scenario }}
|
||||||
|
env:
|
||||||
|
name: ${{ matrix.config.name }}
|
||||||
|
@ -35,7 +35,7 @@ Ansible:
|
|||||||
|
|
||||||
## :warning: Requirements
|
## :warning: Requirements
|
||||||
|
|
||||||
Ansible >= 2.9
|
Ansible >= 2.10
|
||||||
|
|
||||||
## :zap: Installation
|
## :zap: Installation
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
- name: Restart sshd
|
- name: Restart sshd
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: sshd
|
name: sshd
|
||||||
state: restarted
|
state: restarted
|
||||||
|
@ -7,7 +7,7 @@ galaxy_info:
|
|||||||
|
|
||||||
license: "MPL2"
|
license: "MPL2"
|
||||||
|
|
||||||
min_ansible_version: 2.9
|
min_ansible_version: "2.10"
|
||||||
|
|
||||||
galaxy_tags: ['claranet', 'motd', 'system', 'dynmotd', 'dynamic']
|
galaxy_tags: ['claranet', 'motd', 'system', 'dynmotd', 'dynamic']
|
||||||
|
|
||||||
|
@ -14,8 +14,11 @@ ENV {{ var }} {{ value }}
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python3 sudo bash ca-certificates iproute2 systemd && apt-get clean; \
|
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python3 sudo bash ca-certificates iproute2 systemd wget && apt-get clean; \
|
||||||
elif [ $(command -v yum) ]; then yum install -y python3 sudo bash iproute systemd firewalld initscripts; \
|
elif [ $(command -v yum) ]; then yum install -y python3 sudo bash iproute systemd initscripts wget; \
|
||||||
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml iproute2 && zypper clean -a; \
|
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml iproute2 wget && zypper clean -a; \
|
||||||
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
|
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates wget; \
|
||||||
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates iproute2 && xbps-remove -O; fi
|
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates iproute2 wget && xbps-remove -O; fi
|
||||||
|
|
||||||
|
RUN wget -O /usr/bin/systemctl https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl3.py && \
|
||||||
|
chmod +x /usr/bin/systemctl
|
||||||
|
@ -6,7 +6,9 @@ driver:
|
|||||||
name: docker
|
name: docker
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: claranet_motd_${image:-debian}-${tag:-latest}
|
# On "${name:-${image:-debian}", the last brace does not miss, it works like that...
|
||||||
|
# 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}
|
image: ${image:-debian}:${tag:-latest}
|
||||||
privileged: true
|
privileged: true
|
||||||
tty: true
|
tty: true
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
- name: configure_motd | Apply template {{ motd_template }} on {{ _motd_file_path }}
|
- name: configure_motd | Apply template {{ motd_template }} on {{ _motd_file_path }}
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
content: "{{ motd_template_prepend + _motd_template_content + motd_template_append }}"
|
content: "{{ motd_template_prepend + _motd_template_content + motd_template_append }}"
|
||||||
dest: "{{ _motd_file_path }}"
|
dest: "{{ _motd_file_path }}"
|
||||||
owner: root
|
owner: root
|
||||||
@ -10,7 +10,7 @@
|
|||||||
- molecule-idempotence-notest
|
- molecule-idempotence-notest
|
||||||
|
|
||||||
- name: configure_motd | Add pam_exec {{ _motd_file_path }} in pam
|
- name: configure_motd | Add pam_exec {{ _motd_file_path }} in pam
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
line: session optional pam_exec.so type=open_session stdout {{ _motd_file_path }}
|
line: session optional pam_exec.so type=open_session stdout {{ _motd_file_path }}
|
||||||
loop:
|
loop:
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
---
|
---
|
||||||
- name: disable_default_motd | Get stats of {{ _motd_sshd_config_file_path }}
|
- name: disable_default_motd | Get stats of {{ _motd_sshd_config_file_path }}
|
||||||
stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ _motd_sshd_config_file_path }}"
|
path: "{{ _motd_sshd_config_file_path }}"
|
||||||
register: _motd_sshd_config_file_stat
|
register: _motd_sshd_config_file_stat
|
||||||
|
|
||||||
- name: disable_default_motd | Ensure PrintMotd is set to "no" in {{ _motd_sshd_config_file_path }}
|
- name: disable_default_motd | Ensure PrintMotd is set to "no" in {{ _motd_sshd_config_file_path }}
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ _motd_sshd_config_file_path }}"
|
path: "{{ _motd_sshd_config_file_path }}"
|
||||||
regexp: "^PrintMotd "
|
regexp: "^PrintMotd "
|
||||||
line: PrintMotd no
|
line: PrintMotd no
|
||||||
when: _motd_sshd_config_file_stat.stat.exists
|
when: _motd_sshd_config_file_stat.stat.exists
|
||||||
|
|
||||||
- name: disable_default_motd | Comment out pam_motd in pam
|
- name: disable_default_motd | Comment out pam_motd in pam
|
||||||
replace:
|
ansible.builtin.replace:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
regexp: '^(session\s+optional\s+pam_motd.so\s+.*)'
|
regexp: '^(session\s+optional\s+pam_motd.so\s+.*)'
|
||||||
replace: '# \1'
|
replace: '# \1'
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
---
|
---
|
||||||
- name: include_tasks disable_default_motd.yml if motd_disable_default_motd is True
|
- name: Include disable_default_motd.yml if motd_disable_default_motd is True
|
||||||
include_tasks: disable_default_motd.yml
|
ansible.builtin.include_tasks: disable_default_motd.yml
|
||||||
when: motd_disable_default_motd|bool
|
when: motd_disable_default_motd|bool
|
||||||
|
|
||||||
- include_tasks: configure_motd.yml
|
- name: Include configure_motd.yml
|
||||||
|
ansible.builtin.include_tasks: configure_motd.yml
|
||||||
...
|
...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user