not working
This commit is contained in:
parent
e5c6fbf888
commit
c483ff9a6c
5 changed files with 54 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
|||
# win_ansible_role_wallpaper
|
||||
|
||||
Ansible role to set walpaper on windows
|
||||
|
||||
!!! NOT WORKING
|
||||
|
|
4
defaults/main.yml
Normal file
4
defaults/main.yml
Normal 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
8
handlers/main.yml
Normal 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
18
tasks/main.yml
Normal 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 }}'
|
21
templates/set_wallpaper.ps1.j2
Normal file
21
templates/set_wallpaper.ps1.j2
Normal 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 }})
|
Loading…
Reference in a new issue