From b53644731950306207f65f7e2b5780dbe72b2f9c Mon Sep 17 00:00:00 2001 From: L3D Date: Sat, 31 Dec 2022 20:10:59 +0100 Subject: [PATCH] Add initial ansible --- LICENSE | 2 +- defaults/main.yml | 2 ++ tasks/activate.yml | 13 +++++++++++++ tasks/main.yml | 15 +++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 defaults/main.yml create mode 100644 tasks/activate.yml create mode 100644 tasks/main.yml diff --git a/LICENSE b/LICENSE index 2071b23..22cd01f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) +Copyright (c) 2022 L3D Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..70b3c05 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,2 @@ +--- +windows_product_key: 'undefined' diff --git a/tasks/activate.yml b/tasks/activate.yml new file mode 100644 index 0000000..d72d40a --- /dev/null +++ b/tasks/activate.yml @@ -0,0 +1,13 @@ +--- +- name: Check if product key is defined + ansible.builtin.fail: + msg: Plese define windows product key + when: windows_product_key == 'undefined' + +- name: Set windows product key + ansible.windows.win_powershell: + script: 'cscript.exe "slmgr.vbs" /ipk {{ windows_product_key }}' + +- name: Akivate Windows + ansible.windows.win_powershell: + script: "cscript.exe 'slmgr.vbs' /ato" diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..816323c --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,15 @@ +--- +- name: Get product id and product key + community.windows.win_product_facts: + +- name: Display Windows edition + debug: + var: ansible_os_license_edition + +- name: Display Windows license status + debug: + var: ansible_os_license_status + +- name: activate windows + ansible.builtin.include_tasks: activate.yml + when: ansible_os_license_edition != "Windows(R), Enterprise edition" or ansible_os_license_status != "Licensed"