diff --git a/ansible/firstboot.yml b/ansible/firstboot.yml index e57d0fe..be74981 100644 --- a/ansible/firstboot.yml +++ b/ansible/firstboot.yml @@ -20,3 +20,8 @@ ansible.builtin.service: name: linuxinstaller-firstboot enabled: true + + - name: Ajoute extra_packages + ansible.builtin.package: + name: "{{ extra_packages }}" + when: extra_packages is defined diff --git a/config.yml b/config.yml index 5832360..038797f 100644 --- a/config.yml +++ b/config.yml @@ -5,6 +5,9 @@ ansiblemenu: argument_help: Ne présente pas le menu et prépare le système au premier démarrage playbook: firstboot.yml menu_hidden: true + extra_vars: + extra_packages: + - apt-auto-update update: menu_title: Exécuter la mise à jour des paquets diff --git a/linuxinstaller/AnsibleActions.py b/linuxinstaller/AnsibleActions.py index 93d8977..bbb0428 100644 --- a/linuxinstaller/AnsibleActions.py +++ b/linuxinstaller/AnsibleActions.py @@ -1,7 +1,13 @@ import subprocess - +import json + def runAnsiblePlaybook(config, key): - subprocess.check_call(['ansible-playbook', config['ansiblemenu'][key]['playbook']], cwd=config['base_path']) + if config['ansiblemenu'][key]['extra_vars'] is null: + subprocess.check_call(['ansible-playbook', config['ansiblemenu'][key]['playbook']], cwd=config['base_path']) + else: + subprocess.check_call(['ansible-playbook', config['ansiblemenu'][key]['playbook'], + '--extra-vars', json.dumps(config['ansiblemenu'][key]['extra_vars']) ], + cwd=config['base_path']) def pullAnsiblePlaybook(url, playbook): subprocess.check_call(['ansible-pull', '-U', url, playbook])