diff --git a/config.yml.example b/config.yml.example index d29ef0a..e2d42bb 100644 --- a/config.yml.example +++ b/config.yml.example @@ -2,6 +2,8 @@ base_path: ansible ### Titre du menu title: Menu de configuration Libretic +### Branche git souhaitée - avertit si la branche constatée est différente +git_branch: main ### Liste des playbooks ansible # ansible_playbooks: diff --git a/linuxinstaller/PythonActions.py b/linuxinstaller/PythonActions.py index 61381d3..ccf22f1 100644 --- a/linuxinstaller/PythonActions.py +++ b/linuxinstaller/PythonActions.py @@ -18,7 +18,7 @@ def setFQDN(fqdn): ### Cartouche de status -def print_status(menuTitle): +def print_status(menuTitle, gitBranch): # Récupération des infos hostname = getHostName() domain = getDomain() @@ -33,9 +33,8 @@ def print_status(menuTitle): table.add_column("Paramètre", style="bold magenta") table.add_column("Valeur") table.add_column("Statut", justify="center") - table.add_row("Environnement du poste", currentBranch, "[green]OK" if currentBranch == "main" else "[yellow]Attention") + table.add_row("Environnement du poste", currentBranch, "[green]OK" if currentBranch == gitBranch else "[yellow]Attention") table.add_row("Hostname", hostname, "[green]OK" if hostname != "unassigned-hostname" else "[red]KO") console.print(table) console.print() - diff --git a/linuxinstaller/linuxinstaller.py b/linuxinstaller/linuxinstaller.py index 1aa7c76..5d4777a 100644 --- a/linuxinstaller/linuxinstaller.py +++ b/linuxinstaller/linuxinstaller.py @@ -102,10 +102,8 @@ def main(): config = readConfig("config.yml") currentBranch = GitActions.getBranch() - if 'title' in config: - title=config['title'] - else: - title="Menu de configuration linuxinstaller" + title = config['title'] if 'title' in config else "Menu de configuration linuxinstaller" + gitBranch = config['git_branch'] if 'git_branch' in config else "main" parser = argparse.ArgumentParser(description=title) parser.add_argument("--tags", help="Exécute les playbooks portant ces étiquettes", action="extend", nargs="+", type=str) @@ -152,7 +150,7 @@ def main(): while not cmdlineOptionPassed: - PythonActions.print_status(title) + PythonActions.print_status(title, gitBranch) console = Console() console.print("Choisir une des options suivantes", style="bold blue") action = inquirer.select(