Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compability with ansible-lint, yamllint and ShellCheck #274

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
4 changes: 2 additions & 2 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
name: Molecule Test
on: [push, pull_request]
on: [ push, pull_request ] # yamllint disable-line rule:truthy
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 2
matrix:
ansible: ["2.10", "latest"]
ansible: [ "2.10", "latest" ]
steps:
- uses: actions/checkout@v2
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/monthly.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Monthly Molecule Test
on:
on: # yamllint disable-line rule:truthy
schedule:
# Run on the 10th of each month at noon.
- cron: '00 12 10 * *'
Expand All @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ansible: ["latest"]
ansible: [ "latest" ]
steps:
- uses: actions/checkout@v2
- name: Install dependencies
Expand Down
38 changes: 19 additions & 19 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,35 @@ keepalived_selinux_compile_rules:
- keepalived_ping
- keepalived_setpgid

#keepalived_package_state: "latest"
# keepalived_package_state: "latest"
keepalived_package_state: "{{ ( (keepalived_use_latest_stable | default(true)) | bool) | ternary('latest','present') }}"

# Keepalived scripts can be defined that trigger notification scripts.
# Examples have been provided below and in the tests directory.
# keepalived_scripts:
#haproxy_check_script:
# check_script: "/etc/keepalived/haproxy_check.sh"
# ##if a src_check_script is defined, it will be uploaded from src_check_script
# ##on the deploy host to the check_script location. If the check_script needs
# ##parameters, you can define the location under dest_check_script.
# src_check_script: "{{ playbook_dir }}/../scripts/keepalived_haproxy_check.sh"
#haproxy_check_script:
# Here is an example with a command instead of a script.
# Add src_check_script if you want to run a script instead of a command
#check_script: "killall -0 haproxy"
# haproxy_check_script:
# check_script: "/etc/keepalived/haproxy_check.sh"
# ##if a src_check_script is defined, it will be uploaded from src_check_script
# ##on the deploy host to the check_script location. If the check_script needs
# ##parameters, you can define the location under dest_check_script.
# src_check_script: "{{ playbook_dir }}/../scripts/keepalived_haproxy_check.sh"
# haproxy_check_script:
# Here is an example with a command instead of a script.
# Add src_check_script if you want to run a script instead of a command
# check_script: "killall -0 haproxy"
keepalived_scripts: {}

# Keepalived scripts may rely upon additional packages.
keepalived_scripts_packages: []

#This is the expiration time of your package manager cache.
#When expired, this role will require to update the package manger cache.
#This variable will be removed when the ansible upstream bugs will be fixed.
# This is the expiration time of your package manager cache.
# When expired, this role will require to update the package manger cache.
# This variable will be removed when the ansible upstream bugs will be fixed.
cache_timeout: 600

keepalived_instances: {}
keepalived_sync_groups: {}
keepalived_bind_on_non_local: False
keepalived_bind_on_non_local: false

# In case of VIP failover some applications might stuck on retrying to send
# data without updating ARP. This variable defines amount of retries kernel
Expand All @@ -64,17 +64,17 @@ keepalived_sysctl_tcp_retries: 8
# This list of strings will appear in the global_defs section of the
# keepalived configuration file.
# Example:
#keepalived_global_defs:
# keepalived_global_defs:
# - enable_script_security

# Whether to add systemd overrides for keepalived:
# Wants=network-online.target
# After=network-online.target
keepalived_systemd_overrides: True
keepalived_systemd_overrides: true

# Whether to add systemd option Restart=always
# It depends on bool keepalived_systemd_overrides, so to add both must be True
keepalived_systemd_override_service_restart: False
keepalived_systemd_override_service_restart: false

# Set location of keepalived daemon options file path
# For Debian based systems it's usually /etc/default/keepalived
Expand All @@ -84,6 +84,6 @@ keepalived_daemon_options_file_path: "{{ _keepalived_daemon_options_file_path }}
# Overriding keepalived daemon extra arguments, which will be applied inside of
# the keepalived_daemon_options_file_path variable.
# Example:
#keepalived_daemon_default_options_overrides:
# keepalived_daemon_default_options_overrides:
# - "DAEMON_ARGS='--snmp'"
keepalived_daemon_default_options_overrides: []
2 changes: 1 addition & 1 deletion files/keepalived_notifications.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#TYPE=$1
#NAME=$2
NOW=`date "+%Y-%m-%d %H:%M:%S"`
NOW=$(date "+%Y-%m-%d %H:%M:%S")
NEWSTATE=$3

echo "$NEWSTATE" > /var/run/keepalived.state
Expand Down
30 changes: 15 additions & 15 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ galaxy_info:
min_ansible_version: "2.10"

platforms:
- name: "EL"
versions:
- "8"
- name: "Ubuntu"
versions:
- "xenial"
- "bionic"
- "focal"
- name: "Debian"
- name: "EL"
versions:
- "8"
- name: "Ubuntu"
versions:
- "xenial"
- "bionic"
- "focal"
- name: "Debian"
galaxy_tags:
- "clustering"
- "networking"
- "system"
- "vrrp"
- "vip"
- "lvs"
- "clustering"
- "networking"
- "system"
- "vrrp"
- "vip"
- "lvs"

dependencies: []
8 changes: 4 additions & 4 deletions molecule/default/cleanup.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
- name: Cleanup default molecule scenario
hosts: all[0]
gather_facts: no
gather_facts: false
tasks:
- name: Create a network with custom IPAM config
delegate_to: localhost
community.docker.docker_network:
- name: Create a network with custom IPAM config
delegate_to: localhost
community.docker.docker_network:
name: keepalived-network
state: absent
80 changes: 40 additions & 40 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,50 @@
- "1"
- "100%"
tasks:
- name: Show some details for debug
ansible.builtin.debug:
msg: "Family {{ ansible_os_family }} and ansible version {{ ansible_version['string'] }}"
- name: Show some details for debug
ansible.builtin.debug:
msg: "Family {{ ansible_os_family }} and ansible version {{ ansible_version['string'] }}"

- name: Install basic packages
ansible.builtin.package:
update_cache: "{{ ansible_os_family == 'Debian' | ternary('yes', omit) }}"
name: "{{ packagelist[ansible_os_family] | default([]) }}"
state: present
vars:
packagelist:
Debian:
- iproute2
RedHat:
- iproute
- iputils
Rocky:
- iproute
- iputils
- name: Install basic packages
ansible.builtin.package:
update_cache: "{{ ansible_os_family == 'Debian' | ternary('yes', omit) }}"
name: "{{ packagelist[ansible_os_family] | default([]) }}"
state: present
vars:
packagelist:
Debian:
- iproute2
RedHat:
- iproute
- iputils
Rocky:
- iproute
- iputils

- name: Add a container to a network, leaving existing containers connected
delegate_to: localhost
community.docker.docker_network:
name: keepalived-network
connected:
- "{{ inventory_hostname }}"
appends: yes
- name: Add a container to a network, leaving existing containers connected
delegate_to: localhost
community.docker.docker_network:
name: keepalived-network
connected:
- "{{ inventory_hostname }}"
appends: true

- name: Re-collect network facts required after installation iproute
ansible.builtin.setup:
gather_subset: network
- name: Re-collect network facts required after installation iproute
ansible.builtin.setup:
gather_subset: network

- name: Show ansible_interfaces
ansible.builtin.debug:
var: ansible_interfaces
- name: Show ansible_interfaces
ansible.builtin.debug:
var: ansible_interfaces

- name: Define vrrp nic
ansible.builtin.set_fact:
vrrp_nic: "{{ ((ansible_interfaces | reject('equalto','lo')) | difference([ansible_default_ipv4.interface]))[0] | string }}"
- name: Define vrrp nic
ansible.builtin.set_fact:
vrrp_nic: "{{ ((ansible_interfaces | reject('equalto','lo')) | difference([ansible_default_ipv4.interface]))[0] | string }}"

- name: Include keepalived vars
ansible.builtin.include_vars:
file: ../../tests/keepalived_haproxy_combined_example.yml
- name: Include keepalived vars
ansible.builtin.include_vars:
file: ../../tests/keepalived_haproxy_combined_example.yml

- name: Include ansible-keepalived
ansible.builtin.include_role:
name: ansible-keepalived
- name: Include ansible-keepalived
ansible.builtin.include_role:
name: ansible-keepalived
24 changes: 12 additions & 12 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,50 @@ verifier:
provisioner:
name: ansible
options:
v: True
log: True
v: true
log: true
platforms:
- name: keepalived-rockylinux8
pre_build_image: yes
pre_build_image: true
image: geerlingguy/docker-rockylinux8-ansible:latest
privileged: true
command: /sbin/init
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /sys/fs/cgroup:/sys/fs/cgroup:ro

- name: keepalived-bullseye
pre_build_image: yes
pre_build_image: true
image: geerlingguy/docker-debian11-ansible:latest
privileged: true
command: /lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /sys/fs/cgroup:/sys/fs/cgroup:ro
service_manager: systemd

- name: keepalived-xenial
pre_build_image: yes
pre_build_image: true
image: geerlingguy/docker-ubuntu1604-ansible:latest
privileged: true
command: /lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /sys/fs/cgroup:/sys/fs/cgroup:ro
service_manager: systemd

- name: keepalived-bionic
pre_build_image: yes
pre_build_image: true
image: geerlingguy/docker-ubuntu1804-ansible:latest
privileged: true
command: /lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /sys/fs/cgroup:/sys/fs/cgroup:ro

- name: keepalived-focal
pre_build_image: yes
pre_build_image: true
image: geerlingguy/docker-ubuntu2004-ansible:latest
privileged: true
command: /lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /sys/fs/cgroup:/sys/fs/cgroup:ro
16 changes: 8 additions & 8 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
- name: Prepare molecule instance
hosts: all[0]
tasks:
- name: Create a network with custom IPAM config
delegate_to: localhost
community.docker.docker_network:
name: keepalived-network
ipam_config:
- subnet: 192.168.33.0/24
gateway: 192.168.33.254
iprange: 192.168.33.0/26
- name: Create a network with custom IPAM config
delegate_to: localhost
community.docker.docker_network:
name: keepalived-network
ipam_config:
- subnet: 192.168.33.0/24
gateway: 192.168.33.254
iprange: 192.168.33.0/26
4 changes: 2 additions & 2 deletions molecule/default/side_effect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
- name: Compare all the hosts IPs with the vrrp_ip
ansible.builtin.set_fact:
is_there_master_ip_somewhere: "{{ ansible_play_hosts_all | map('extract', hostvars, 'ansible_all_ipv4_addresses') | flatten | intersect([vrrp_ip]) }}"
run_once: True
run_once: true

- name: Fail if no one has the vrrp_ip
ansible.builtin.assert:
that:
is_there_master_ip_somewhere | length > 0
run_once: True
run_once: true

# Check master is back online is done on verify
- name: Restore network connectivity on the initial master node
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
hosts: all
# This is necessary to ensure the _first_ node is indeed master
order: sorted
gather_facts: yes
gather_facts: true
tasks:
- name: Define vrrp nic
ansible.builtin.set_fact:
Expand Down
Loading