Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/test-and-lint' into test-and-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dlundgren committed Jun 7, 2024
2 parents 7faa0b1 + 188fdcb commit a41a8f0
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 48 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
---
name: Release to Ansible Galaxy

on:
push:
tags:
- '*'
schedule:
- cron: '1 10 14 * *'
on: # yamllint disable-line rule:truthy
workflow_dispatch:
release:
types: [published]

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: galaxy
uses: robertdebock/[email protected]
- name: publish to galaxy
uses: ansible-actions/[email protected]
with:
galaxy_version: ${{ github.ref_name }}
galaxy_api_key: ${{ secrets.galaxy_api_key }}
34 changes: 16 additions & 18 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Ansible Molecule

on:
on: # yamllint disable-line rule:truthy
workflow_dispatch:
push:
tags_ignore:
- '*'
Expand All @@ -20,30 +20,28 @@ jobs:
test:
needs:
- lint
runs-on: ubuntu-latest
# services:
# nginx:
# image: nginx
# ports:
# - 80:80
# volumes:
# - "${GITHUB_WORKSPACE}/molecule/default/files:/usr/share/nginx/html:ro"
runs-on: ubuntu
strategy:
fail-fast: false
matrix:
config:
- image: amazonlinux
tag: latest
- image: amazonlinux2
- image: ubuntu2204
- image: rockylinux8
steps:
- name: checkout
uses: actions/checkout@v4
with:
path: "${{ github.repository }}"
- name: molecule
uses: robertdebock/[email protected]
- name: Set up Python 3.
uses: actions/setup-python@v5
with:
image: ${{ matrix.config.image }}
tag: ${{ matrix.config.tag }}
options: "--parallel all"
python-version: '3.x'
- name: Install test dependencies.
run: pip3 install ansible molecule-docker docker
- name: molecule
run: molecule test
env:
TOX_PARALLEL_NO_SPINNER: 1
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
image: ${{ matrix.image }}
40 changes: 40 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
# Based on ansible-lint config
extends: default
ignore: |
venv/
scripts/
molecule.yml
rules:
line-length:
max: 120
level: warning
rulesa:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
colons:
max-spaces-after: -1
level: error
commas:
max-spaces-after: -1
level: error
comments: disable
comments-indentation: disable
document-start: disable
empty-lines:
max: 3
level: error
hyphens:
level: error
indentation: disable
key-duplicates: enable
line-length: disable
new-line-at-end-of-file: disable
new-lines:
type: unix
trailing-spaces: disable
truthy: disable
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ bigfix_client_conf_dir: /etc/opt/BESClient
bigfix_client_server_name: bigfix.example.com
bigfix_client_server_port: 52311
bigfix_client_service_name: besclient

__bigfix_ansible_distro_arch: "{{ ansible_distribution_version.split('.')[0] }}-{{ ansible_architecture }}"
6 changes: 6 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Restart bigfix-client
ansible.builtin.service:
name: "{{ bigfix_client_service_name }}"
state: restarted
enabled: true
4 changes: 3 additions & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
update_cache: true

- name: Copy the debug masthead
ansible.builtin.copy: # noqa: risky-file-permissions
ansible.builtin.copy: # noqa: risky-file-permissions
src: masthead/
dest: /usr/share/nginx/html/masthead

- name: Restart nginx
ansible.builtin.service:
name: nginx
state: restarted
# we don't care about the idempotence on this
changed_when: false

- name: Converge
hosts: all:!nginx
Expand Down
15 changes: 9 additions & 6 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ driver:
name: docker
platforms:
- name: nginx
image: nginx
- name: "bigfix-client-${image:-amazonlinux}-${tag:-latest}${TOX_ENVNAME}"
image: "${namespace:-robertdebock}/${image:-amazonlinux}:${tag:-latest}"
command: /sbin/init
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
image: nginx:mainline-alpine-slim
- name: "bigfix-client-${image:-ubuntu2204}-${tag:-latest}${TOX_ENVNAME}"
image: "geerlingguy/docker-${image:-ubuntu2204}-ansible:latest"
privileged: true
pre_build_image: true
cgroupns_mode: host
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
- /run
- /run/lock
provisioner:
name: ansible
config_options:
Expand Down
2 changes: 1 addition & 1 deletion tasks/install/AIX.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

- name: Install BigFix Client
ansible.builtin.command:
cmd: "installp –agqYXd /tmp/{{ bigfix_client_file_name }} BESClient" # noqa: no-changed-when
cmd: "installp –agqYXd /tmp/{{ bigfix_client_file_name }} BESClient" # noqa: no-changed-when
2 changes: 1 addition & 1 deletion tasks/install/HP-UX.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---

- name: Install BigFix Client
ansible.builtin.command: # noqa: no-changed-when
ansible.builtin.command: # noqa: no-changed-when
cmd: "/usr/sbin/swinstall -s {{ ansible_hostname }}:/tmp/{{ bigfix_client_file_name }} BESAgent"
2 changes: 1 addition & 1 deletion tasks/install/Solaris.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---

- name: Install BigFix Client
community.general.svr4pkg: # noqa: args[module]
community.general.svr4pkg: # noqa: args[module]
src: "/tmp/{{ bigfix_client_file_name }}"
state: present
14 changes: 5 additions & 9 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---

- name: Load OS specific vars
ansible.builtin.include_vars: "{{ ansible_distribution }}-{{ ansible_distribution_version.split('.')[0] }}-{{ ansible_architecture }}.yml"
ansible.builtin.include_vars: "{{ ansible_distribution }}-{{ __bigfix_ansible_distro_arch }}.yml"

- name: Load OS Family specific vars
when: bigfix_client_file_sum is not defined
ansible.builtin.include_vars: "{{ ansible_os_family }}-{{ ansible_distribution_version.split('.')[0] }}-{{ ansible_architecture }}.yml"
ansible.builtin.include_vars: "{{ ansible_os_family }}-{{ __bigfix_ansible_distro_arch }}.yml"

- name: Failing due to undetermined OS
ansible.builtin.fail:
Expand All @@ -27,14 +27,10 @@
register: masthead_file

- name: Download masthead from BigFix Server
when: not masthead_file.stat.exists
ansible.builtin.get_url:
url: "http://{{ bigfix_client_server_name }}:{{ bigfix_client_server_port }}/masthead/masthead.afxm"
dest: "{{ bigfix_client_conf_dir }}/actionsite.afxm"
mode: "0644"
when: not masthead_file.stat.exists

- name: Start the service
ansible.builtin.service:
name: "{{ bigfix_client_service_name }}"
state: restarted
enabled: true
notify:
- Restart bigfix-client

0 comments on commit a41a8f0

Please sign in to comment.