not working

This commit is contained in:
L3D 2023-02-22 17:39:45 +01:00
parent e5c6fbf888
commit c483ff9a6c
Signed by: l3d
GPG key ID: CD08445BFF4313D1
5 changed files with 54 additions and 1 deletions

View file

@ -1,3 +1,5 @@
# win_ansible_role_wallpaper
Ansible role to set walpaper on windows
Ansible role to set walpaper on windows
!!! NOT WORKING

4
defaults/main.yml Normal file
View file

@ -0,0 +1,4 @@
---
wallpaper_path: false
wallpaper_user_name: "{{ voc_user }}"
wallpaper_user_pwd: "{{ win_obs_init__autologon_password }}"

8
handlers/main.yml Normal file
View file

@ -0,0 +1,8 @@
---
- name: Set Wallpaper
ansible.windows.win_shell: 'C:\Users\{{ wallpaper_user_name }}\.ansible/set_wallpaper.ps1'
become: true
become_method: runas
become_user: "{{ wallpaper_user_name }}"
vars:
ansible_become_pass: '{{ wallpaper_user_pwd }}'

18
tasks/main.yml Normal file
View file

@ -0,0 +1,18 @@
---
- name: Fail if wallpaper_path is unset
ansible.builtin.fail:
msg: please define wallpaper_path
when: wallpaper_path == false
- name: Create .ansible folder
ansible.windows.win_powershell:
script: |
Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name Wallpaper -value "{{ wallpaper_path }}"
Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name TileWallpaper -value "0"
Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name WallpaperStyle -value "10" -Force
changed_when: false
become: true
become_method: runas
become_user: "{{ wallpaper_user_name }}"
vars:
ansible_become_pass: '{{ wallpaper_user_pwd }}'

View file

@ -0,0 +1,21 @@
{{ ansible_managed | comment }}
$setwallpapersrc = @"
using System.Runtime.InteropServices;
public class Wallpaper
{
public const int SetDesktopWallpaper = 20;
public const int UpdateIniFile = 0x01;
public const int SendWinIniChange = 0x02;
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
public static void SetWallpaper(string path)
{
SystemParametersInfo(SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange);
}
}
"@
Add-Type -TypeDefinition $setwallpapersrc
[Wallpaper]::SetWallpaper({{ wallpaper_path }})