Fix linting issues
ci/woodpecker/push/woodpecker Pipeline failed Details

This commit is contained in:
Santiago Lo Coco 2024-04-14 19:42:14 +02:00
parent 6b2177d8ee
commit 4ce291e708
11 changed files with 23 additions and 22 deletions

View File

@ -6,8 +6,8 @@ steps:
image: alpine/git image: alpine/git
commands: commands:
- apk add ansible ansible-lint - apk add ansible ansible-lint
#- cd slococo/playground # - cd slococo/playground
#- ansible-galaxy collection install . # - ansible-galaxy collection install .
- ansible-galaxy collection install -r slococo/playground/requirements.yml - ansible-galaxy collection install -r slococo/playground/requirements.yml
- ansible-lint - ansible-lint
- ls -al - ls -al

View File

@ -7,7 +7,7 @@
- role: slococo.playground.ssh_config - role: slococo.playground.ssh_config
- role: slococo.playground.local_accounts - role: slococo.playground.local_accounts
vars: vars:
accounts: local_accounts_list:
- name: local_adm - name: local_adm
shell: /bin/bash shell: /bin/bash
userid: 38000087 userid: 38000087

View File

@ -13,7 +13,7 @@ Role Variables
-------------- --------------
```yaml ```yaml
accounts: local_accounts_list:
- name: # Username for the local user (required) - name: # Username for the local user (required)
shell: # Shell for the local user (required) shell: # Shell for the local user (required)
userid: # User ID for the local user (required) userid: # User ID for the local user (required)
@ -28,7 +28,7 @@ Example Playbook
```yaml ```yaml
- hosts: servers - hosts: servers
vars: vars:
accounts: local_accounts_list:
- name: test_user1 - name: test_user1
shell: /bin/bash shell: /bin/bash
userid: 1001 userid: 1001

View File

@ -1,2 +1,2 @@
--- ---
accounts: [] local_accounts_list: []

View File

@ -3,7 +3,7 @@ argument_specs:
main: main:
short_description: Ansible Role to create local users short_description: Ansible Role to create local users
options: options:
accounts: local_accounts_list:
type: list type: list
required: true required: true
elements: dict elements: dict
@ -42,6 +42,6 @@ argument_specs:
description: Boolean value indicating whether SSH key pairs should be generated for passwordless authentication. description: Boolean value indicating whether SSH key pairs should be generated for passwordless authentication.
private_key_path: private_key_path:
type: str type: str
required: no required: false
default: /tmp default: /tmp
description: "Path to the private key on the Ansible control node. If not provided, the default path will be /tmp." description: "Path to the private key on the Ansible control node. If not provided, the default path will be /tmp."

View File

@ -7,16 +7,16 @@
expires: "{{ (((item.expiry_date + ' 00:00:00') | to_datetime).strftime('%s')) if item.expiry_date is defined else omit }}" expires: "{{ (((item.expiry_date + ' 00:00:00') | to_datetime).strftime('%s')) if item.expiry_date is defined else omit }}"
home: "{{ item.home | default(omit) }}" home: "{{ item.home | default(omit) }}"
groups: "{{ item.groups | default(omit) }}" groups: "{{ item.groups | default(omit) }}"
loop: "{{ accounts }}" loop: "{{ local_accounts_list }}"
- name: Add home - name: Add home
ansible.builtin.set_fact: ansible.builtin.set_fact:
accounts_with_home: "{{ accounts_with_home | default([]) + [item | combine({'home': item.home | default('/home/' + item.name)})] }}" accounts_with_home: "{{ accounts_with_home | default([]) + [item | combine({'home': item.home | default('/home/' + item.name)})] }}"
loop: "{{ accounts }}" loop: "{{ local_accounts_list }}"
- name: Determine key path - name: Determine key path
set_fact: ansible.builtin.set_fact:
key_path: "{{ (private_key_path | default('/tmp')) | regex_replace('/$','') }}/id_rsa" key_path: "{{ (private_key_path | default('/tmp')) | regex_replace('/$', '') }}/id_rsa"
- name: Generate SSH key pairs for local users - name: Generate SSH key pairs for local users
community.crypto.openssh_keypair: community.crypto.openssh_keypair:
@ -31,6 +31,7 @@
ansible.builtin.file: ansible.builtin.file:
path: "{{ item.home }}/.ssh" path: "{{ item.home }}/.ssh"
state: directory state: directory
mode: '0700'
loop: "{{ accounts_with_home }}" loop: "{{ accounts_with_home }}"
when: item.passwordless | default(false) | bool when: item.passwordless | default(false) | bool

View File

@ -2,11 +2,11 @@
- name: Test the local_accounts role - name: Test the local_accounts role
hosts: localhost hosts: localhost
connection: local connection: local
gather_facts: no gather_facts: false
become: true become: true
vars: vars:
accounts: local_accounts_list:
- name: test_user1 - name: test_user1
shell: /bin/bash shell: /bin/bash
userid: 1001 userid: 1001
@ -18,4 +18,4 @@
groups: docker groups: docker
roles: roles:
- {role: ../..} - role: slococo.playground.local_accounts

View File

@ -1,5 +1,5 @@
--- ---
options: ssh_config_options:
PasswordAuthentication: 'yes' PasswordAuthentication: 'yes'
PermitEmptyPasswords: 'no' PermitEmptyPasswords: 'no'
PermitRootLogin: 'no' PermitRootLogin: 'no'

View File

@ -3,7 +3,7 @@ argument_specs:
main: main:
short_description: Ansible Role to manage SSH configuration short_description: Ansible Role to manage SSH configuration
options: options:
options: ssh_config_options:
type: dict type: dict
required: false required: false
default: default:

View File

@ -6,6 +6,6 @@
line: "{{ item.key }} {{ item.value }}" line: "{{ item.key }} {{ item.value }}"
state: present state: present
validate: "sshd -t -f %s" validate: "sshd -t -f %s"
mode: 0644 mode: '0644'
loop: "{{ options | dict2items }}" loop: "{{ ssh_config_options | dict2items }}"
notify: Restart SSH service notify: Restart SSH service

View File

@ -2,12 +2,12 @@
- name: Test the ssh_config role - name: Test the ssh_config role
hosts: localhost hosts: localhost
connection: local connection: local
gather_facts: no gather_facts: false
become: true become: true
vars: vars:
options: ssh_config_options:
PasswordAuthentication: 'no' PasswordAuthentication: 'no'
roles: roles:
- {role: ../..} - role: slococo.playground.ssh_config