From 64a25c272e08feb36d71ec4dccabaee6fe0c04c1 Mon Sep 17 00:00:00 2001 From: L3D Date: Mon, 20 Dec 2021 19:10:07 +0100 Subject: [PATCH] changing hostname and search updates --- tasks/ansible_user.yml | 2 -- tasks/hostname.yml | 9 +++++++++ tasks/main.yml | 4 ++++ tasks/updates.yml | 9 +++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 tasks/hostname.yml create mode 100644 tasks/updates.yml diff --git a/tasks/ansible_user.yml b/tasks/ansible_user.yml index c7566e1..8fc130b 100644 --- a/tasks/ansible_user.yml +++ b/tasks/ansible_user.yml @@ -20,5 +20,3 @@ - 'Ansibles' - 'Administratoren' - 'Benutzer' - - diff --git a/tasks/hostname.yml b/tasks/hostname.yml new file mode 100644 index 0000000..85c0c12 --- /dev/null +++ b/tasks/hostname.yml @@ -0,0 +1,9 @@ +--- +- name: "Change the hostname to {{ inventory_hostname }}" + ansible.windows.win_hostname: + name: "{{ inventory_hostname }}" + register: res + +- name: Reboot + ansible.windows.win_reboot: + when: res.reboot_required diff --git a/tasks/main.yml b/tasks/main.yml index 25cb8bf..47815fb 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,4 +2,8 @@ - name: create Ansible Windows Group and User ansible.builtin.include_tasks: ansible_user.yml +- name: configure hostname + ansible.builtin.include_tasks: hostname.yml +- name: scan for updates + ansible.builtin.include_tasks: updates.yml diff --git a/tasks/updates.yml b/tasks/updates.yml new file mode 100644 index 0000000..f07794a --- /dev/null +++ b/tasks/updates.yml @@ -0,0 +1,9 @@ +--- +- name: Search-only, return list of found updates (if any), log to C:\ansible_updates.txt + ansible.windows.win_updates: + category_names: + - SecurityUpdates + - CriticalUpdates + - UpdateRollups + state: searched + log_path: C:\ansible_updates.txt