Skip to content

Commit

Permalink
chore: adapt style guide
Browse files Browse the repository at this point in the history
fix: github action pipeline
  • Loading branch information
fadnincx committed Oct 24, 2022
1 parent 78ff97b commit dbf5b2d
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 57 deletions.
5 changes: 3 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
## Description

Please include a summary of the change and which issue is fixed. Please provide the motivation for why this change is necessary at this stage of the product development cycle.
Please include a summary of the changes and which issue is fixed. Describe the
rational why the changes are required at this stage.

Fixes # (issue)

## Depedencies
## Dependencies

Does this PR depend on other PRs of this or a related repository?

Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
test:
runs-on: ubuntu-22.04
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -21,10 +21,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -r molecule-requirements.txt
- name: Lint with ansible-lint including yamllint
run: |
ansible-lint
- name: Test with molecule
run: |
molecule destroy
molecule test
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ansible Playbook - Potos

A magic all inclusive playbook for your custom linux client based on Potos
All inclusive, magic playbook for your custom Potos Linux Clients.

[![Test](https://github.com/projectpotos/ansible-playbook-potos/actions/workflows/test.yml/badge.svg)](https://github.com/projectpotos/ansible-playbook-potos/actions/workflows/test.yml)

Expand Down
22 changes: 11 additions & 11 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
--

dependencies: []
---

galaxy_info:
role_name: 'potos_playbook'
author: 'Adfinis AG'
description: 'This playbook is used to customize potos clients'
company: 'Adfinis AG'
license: 'GNU General Public License v3'
min_ansible_version: '2.12.0'
author: Project Potos
description: Playbook to customize Potos Linux Clients.
company: Project Potos
role_name: play_potos
namespace: projectpotos
license: GPL-3.0-only
min_ansible_version: '2.12'
platforms:
- name: Ubuntu
versions:
- focal
- jammy
galaxy_tags:
- "potos"
- potos

dependencies: []
3 changes: 0 additions & 3 deletions meta/runtime.yml

This file was deleted.

2 changes: 1 addition & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
gather_facts: yes

roles:
- role: potos_wallpaper
- role: ./
1 change: 1 addition & 0 deletions molecule/default/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
localhost ansible_connection=local
4 changes: 2 additions & 2 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ driver:

platforms:
- name: instance
image: ubuntu:22.04
image: ghcr.io/projectpotos/ubuntu22-ansible-test:latest
pre_build_image: yes
command: /sbin/init
command: /lib/systemd/systemd
privileged: yes
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
Expand Down
7 changes: 3 additions & 4 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

---

- name: Prepare
Expand All @@ -7,7 +6,7 @@

tasks:
# Update the apt cache as it's potentialy outdated in the container
- name: update pacman cache
ansible.builtin.command:
apt update && apt upgrade -y
- name: update apt
ansible.builtin.shell: # noqa: command-instead-of-module
apt-get update && apt-get upgrade -y
when: ansible_distribution == 'Ubuntu'
5 changes: 3 additions & 2 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
tasks:
- name: check if some background exists
ansible.builtin.shell:
cmd: ls -p /usr/share/backgrounds | grep -v / | wc -l
cmd: 'ls -p /usr/share/backgrounds | grep -v / | wc -l'
register: out
changed_when: false
failed_when:
- not out.stdout 0
- out.stdout != '0'
18 changes: 9 additions & 9 deletions playbook.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--
---

- name: Potos system configuration
hosts: localhost
Expand All @@ -9,15 +9,15 @@

vars:
# define default run type
potos_runtype: "daily"
potos_runtype: 'daily'

pre_tasks:
# To make sure that this task always executes, it is tagged with the special
# tag "always". Therefore do not remove this tag!
- name: template requirements.yml file
ansible.builtin.template:
src: "requirements.yml.j2"
dest: "{{ playbook_dir }}/requirements.yml"
src: 'requirements.yml.j2'
dest: '{{ playbook_dir }}/requirements.yml'
owner: root
group: root
mode: 0644
Expand All @@ -26,18 +26,18 @@

- name: get required roles with ansible galaxy
ansible.builtin.command:
cmd: /usr/bin/ansible-galaxy install -f -r requirements.yml -p roles/
cmd: '/usr/bin/ansible-galaxy install -f -r requirements.yml -p roles/'
changed_when: false
tags:
- always

tasks:
- name: run all the required roles
include_role:
name: "{{ potos_playbook_role }}"
ansible.builtin.include_role:
name: '{{ potos_playbook_role }}'
apply:
tags:
- always
loop: "{{ lookup('file','requirements.yml') | from_yaml | map(attribute='name') | list }}"
loop: '{{ lookup("file", "requirements.yml") | from_yaml | map(attribute="name") | list }}'
loop_control:
loop_var: "potos_playbook_role"
loop_var: 'potos_playbook_role'
39 changes: 19 additions & 20 deletions prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
pre_tasks:
- name: read specs repo configuration
ansible.builtin.include_vars:
file: "/etc/potos/specs_repo.yml"
file: '/etc/potos/specs_repo.yml'
name: potos_specs_repo
- name: Get specs repo for {{ potos_specs.client_name }}
ansible.builtin.command:
Expand All @@ -23,12 +23,12 @@
tasks:
- name: Check if specs exists
ansible.builtin.stat:
path: "{{ playbook_dir }}/specs"
path: '{{ playbook_dir }}/specs'
register: check_potos_specs

- name: Error handling
ansible.builtin.debug:
msg: "Unable to find an potos specs repo for {{ potos_specs.client_name }}"
msg: 'Unable to find an potos specs repo for {{ potos_specs.client_name }}'
when: not check_potos_specs.stat.exists

- name: Configure playbook for {{ potos_client_name }} with specs
Expand All @@ -37,53 +37,52 @@

- name: Get templates
ansible.builtin.find:
path: "{{ playbook_dir }}/specs/templates"
path: '{{ playbook_dir }}/specs/templates'
recurse: yes
file_type: file
register: potos_playbook_specs_templates

- name: Apply templates
ansible.builtin.template:
src: "{{ item.path }}"
dest: "{{ item.path | regex_replace('^(.*?)\/specs\/templates(.*?)(\.j2)$', '\\1\\2') }}"
src: '{{ item.path }}'
dest: '{{ item.path | regex_replace("^(.*?)\/specs\/templates(.*?)(\.j2)$", "\\1\\2") }}'
loop:
- "{{ potos_playbook_specs.files }}"
- '{{ potos_playbook_specs.files }}'

- name: Get files to copy
ansible.builtin.find:
path: "{{ playbook_dir }}/specs/files"
path: '{{ playbook_dir }}/specs/files'
recurse: yes
file_type: file
register: potos_playbook_specs_files

- name: Copy files
ansible.builtin.copy:
src: "{{ item.path }}"
dest: "{{ item.path | regex_replace('^(.*?)\/specs\/files(.*?)$', '\\1\\2') }}"
src: '{{ item.path }}'
dest: '{{ item.path | regex_replace("^(.*?)\/specs\/files(.*?)$", "\\1\\2") }}'
loop:
- "{{ potos_playbook_specs.files }}"
- '{{ potos_playbook_specs.files }}'

- name: Get vars to copy
ansible.builtin.find:
path: "{{ playbook_dir }}/specs/vars"
path: '{{ playbook_dir }}/specs/vars'
recurse: yes
file_type: file
register: potos_playbook_specs_vars

- name: Copy vars
ansible.builtin.copy:
src: "{{ item.path }}"
dest: "{{ item.path | regex_replace('^(.*?)\/specs\/vars(.*?)$', '\\1/host_vars/all\\2') }}"
src: '{{ item.path }}'
dest: '{{ item.path | regex_replace("^(.*?)\/specs\/vars(.*?)$", "\\1/host_vars/all\\2") }}'
loop:
- "{{ potos_playbook_specs.files }}"
- '{{ potos_playbook_specs.files }}'

- name: Install required collections
ansible.builtin.command:
cmd: /usr/bin/ansible-galaxy collection install -r collections.yml -p /etc/ansible/collections
cmd: '/usr/bin/ansible-galaxy collection install -r collections.yml -p /etc/ansible/collections'
changed_when: False

rescue:
- name: Error handling
ansible.builtin.debug:
msg: "Error while deploying {{ potos_client_name }} ansible vars"

msg: 'Error while deploying {{ potos_client_name }} ansible vars'

0 comments on commit dbf5b2d

Please sign in to comment.