mirror of
https://github.com/DO1JLR/ansible_linux_desktop_setup.git
synced 2024-09-14 19:54:51 +02:00
Merge branch 'dev' of github.com:DO1JLR/ansible_linux_desktop_setup into dev
This commit is contained in:
commit
3ec6b23efe
8 changed files with 104 additions and 14 deletions
15
.github/workflows/pylint.yml
vendored
Normal file
15
.github/workflows/pylint.yml
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
name: 'Pylint GitHub Actions'
|
||||||
|
|
||||||
|
# yamllint disable-line rule:truthy
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pylint:
|
||||||
|
name: 'Pylint'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 'Checkout'
|
||||||
|
uses: actions/checkout@master
|
||||||
|
- name: GitHub Action for pylint
|
||||||
|
uses: cclauss/GitHub-Action-for-pylint@0.7.0
|
2
.github/workflows/yamllint.yaml
vendored
2
.github/workflows/yamllint.yaml
vendored
|
@ -18,5 +18,3 @@ jobs:
|
||||||
yamllint_config_filepath: './.yamllint'
|
yamllint_config_filepath: './.yamllint'
|
||||||
yamllint_strict: false
|
yamllint_strict: false
|
||||||
yamllint_comment: true
|
yamllint_comment: true
|
||||||
# env:
|
|
||||||
# GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }
|
|
||||||
|
|
14
README.md
14
README.md
|
@ -1,14 +1,18 @@
|
||||||
Ansible Linux Desktop Setup
|
Ansible Linux Desktop Setup
|
||||||
==========================
|
==========================
|
||||||
This ansible playbook collection creates [L3D](https://chaos.social/@l3d)s Desktop enviroment. Including window manager and some pre-installed programms like [Firefox](https://www.mozilla.org/de/firefox/new/) and some usefull shell programms.
|
This ansible playbook collection manages some of my workstations and laptops. Because of this it sometimes contains very specific variables like my username, SSH keys or similar data that may not be the best choice for your system.
|
||||||
|
|
||||||
ATTENTION
|
Nevertheless, this ansible playbook is not only publicly available on the internet, but by the MIT license a part of free open-source ansible, which may serve you as inspiration within the framework of the MIT license.
|
||||||
|
|
||||||
|
|
||||||
|
Inventory
|
||||||
-------------
|
-------------
|
||||||
Different to my other ansible playbooks:
|
This is my first ansible with dynamic inventory. The [inventory.py](inventory.py) script looks at which hostname it was lauched on. If the hostname is known, the host is mapped to the group stored for it and a local connection to the host is established.
|
||||||
|
|
||||||
### THIS PLAYBOOK HAS TO BE EXECUTET AT THE TARGET HOST DIRECTLY!
|
This has the advantage that different environments are automatically recognized and significantly less danger of accidentally rolling out the ansible with the variables for a completely different host and thus configuring things that were not intended for this device.
|
||||||
|
|
||||||
|
Obviously, this also means that **this playbook must always be run on the host you want to manage** and this ansible playbook is not meant to be run remotely.
|
||||||
|
|
||||||
*It requires some GUI stuff and I did not find the time to forward X or wayland correctly to make it remotely working. Sorry. Feel free to create a Issue or pull-request*
|
|
||||||
|
|
||||||
Install tipps:
|
Install tipps:
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[defaults]
|
[defaults]
|
||||||
inventory = ./hosts.ini
|
inventory = ./inventory.py
|
||||||
retry_files_enabled = False
|
retry_files_enabled = False
|
||||||
nocows = True
|
nocows = True
|
||||||
ansible_connection = 'local'
|
ansible_connection = 'local'
|
||||||
|
|
73
inventory.py
Executable file
73
inventory.py
Executable file
|
@ -0,0 +1,73 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
Create a dynamic inventory for this ansible playbook
|
||||||
|
"""
|
||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
|
||||||
|
# create a dict to match hostnames to enviroments
|
||||||
|
env_dict = {
|
||||||
|
'work':
|
||||||
|
['workstation.local'],
|
||||||
|
'private':
|
||||||
|
['derpy.local', 'foo.bar']
|
||||||
|
}
|
||||||
|
|
||||||
|
def fqdn():
|
||||||
|
"""
|
||||||
|
return fully qualified domain name
|
||||||
|
"""
|
||||||
|
return socket.getfqdn()
|
||||||
|
|
||||||
|
def env(domain):
|
||||||
|
"""
|
||||||
|
map a hostname to a space
|
||||||
|
or print empty list if no one matched and exit
|
||||||
|
"""
|
||||||
|
for key, values in env_dict.items():
|
||||||
|
if domain in values:
|
||||||
|
return key
|
||||||
|
print(json.dumps(empty_host_list(), sort_keys=True, indent=2))
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
def empty_host_list():
|
||||||
|
"""
|
||||||
|
return empty host list
|
||||||
|
"""
|
||||||
|
comment = "No valid host found. returning empty host list!"
|
||||||
|
return json.loads('{"_meta": {"comment": "' + comment +
|
||||||
|
'", "hostvars": {}}, "instances": {"hosts": []}}')
|
||||||
|
|
||||||
|
def formated_host_group_list(host, group):
|
||||||
|
"""
|
||||||
|
build inventory and return it
|
||||||
|
"""
|
||||||
|
# pylint: disable=line-too-long
|
||||||
|
return json.loads('{"_meta": {"hostvars": {}},"' + str(group) + '": {"hosts": ["' + str(host) + '"]},"instances": {"children": ["' + str(group) + '"]}}')
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""
|
||||||
|
main funktion
|
||||||
|
will analyse on which host this script is started
|
||||||
|
and will print the dynamic inventory to tell ansible
|
||||||
|
which host_vars and group_vars should be used
|
||||||
|
"""
|
||||||
|
host = fqdn()
|
||||||
|
group = env(host)
|
||||||
|
print(json.dumps(formated_host_group_list(host, group), sort_keys=True, indent=2))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#{
|
||||||
|
# "_meta": {
|
||||||
|
# "hostvars": { }
|
||||||
|
# },
|
||||||
|
#
|
||||||
|
# "instances": {
|
||||||
|
# "hosts": ["10.66.70.33"]
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
|
||||||
|
main()
|
Loading…
Reference in a new issue