Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade ansible-lint and fix problems #613

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions plugins/modules/win_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@
ansible.windows.win_command:
# When using argv, each entry is quoted in the module
argv:
- C:\Program Files\My Application\run.exe
- argument 1
- -force
- C:\Program Files\My Application\run.exe
- argument 1
- -force
'''

RETURN = r'''
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/win_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
ansible.windows.win_copy:
src: /srv/myfiles/foo.conf
dest: C:\Temp\renamed-foo.conf
backup: yes
backup: true
- name: Copy a single file keeping the filename
ansible.windows.win_copy:
Expand Down
8 changes: 4 additions & 4 deletions plugins/modules/win_dns_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@
ansible.windows.win_dns_client:
adapter_names: '*'
dns_servers:
- 192.168.34.5
- 192.168.34.6
- 192.168.34.5
- 192.168.34.6
log_path: C:\dns_log.txt
- name: Set IPv6 DNS servers on the adapter named Ethernet
ansible.windows.win_dns_client:
adapter_names: Ethernet
dns_servers:
- '2001:db8::2'
- '2001:db8::3'
- '2001:db8::2'
- '2001:db8::3'
- name: Configure all adapters whose names begin with Ethernet to use DHCP-assigned DNS values
ansible.windows.win_dns_client:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/win_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
- name: Create new Windows domain in a new forest with specific parameters
ansible.windows.win_domain:
create_dns_delegation: no
create_dns_delegation: false
database_path: C:\Windows\NTDS
dns_domain_name: ansible.vagrant
domain_mode: Win2012R2
Expand Down
42 changes: 22 additions & 20 deletions plugins/modules/win_domain_membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,37 +68,39 @@
'''

EXAMPLES = r'''
# host should be a member of domain ansible.vagrant; module will ensure the hostname is mydomainclient
# and will use the passed credentials to join domain if necessary.
# Ansible connection should use local credentials if possible.
# If a reboot is required, the second task will trigger one and wait until the host is available.
- hosts: winclient
- name: Play to join the hsots to a domain
hosts: winclient
gather_facts: false
tasks:
- ansible.windows.win_domain_membership:
dns_domain_name: ansible.vagrant
hostname: mydomainclient
domain_admin_user: testguy@ansible.vagrant
domain_admin_password: password123!
domain_ou_path: "OU=Windows,OU=Servers,DC=ansible,DC=vagrant"
state: domain
register: domain_state
- ansible.windows.win_reboot:
when: domain_state.reboot_required
- name: Join host to the ansible.vagrant domain
ansible.windows.win_domain_membership:
dns_domain_name: ansible.vagrant
hostname: mydomainclient
domain_admin_user: testguy@ansible.vagrant
domain_admin_password: password123!
domain_ou_path: "OU=Windows,OU=Servers,DC=ansible,DC=vagrant"
state: domain
register: domain_state
- name: Reboot host after domain join
ansible.windows.win_reboot:
when: domain_state.reboot_required
# Host should be in workgroup mywg- module will use the passed credentials to clean-unjoin domain if possible.
# Ansible connection should use local credentials if possible.
# The domain admin credentials can be sourced from a vault-encrypted variable
- hosts: winclient
- name: Play to set the hosts workgroup
hosts: winclient
gather_facts: false
tasks:
- ansible.windows.win_domain_membership:
workgroup_name: mywg
domain_admin_user: '{{ win_domain_admin_user }}'
domain_admin_password: '{{ win_domain_admin_password }}'
state: workgroup
- name: Set workgroup to mywg
ansible.windows.win_domain_membership:
workgroup_name: mywg
domain_admin_user: '{{ win_domain_admin_user }}'
domain_admin_password: '{{ win_domain_admin_password }}'
state: workgroup
'''
32 changes: 16 additions & 16 deletions plugins/modules/win_dsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,17 @@
Key: HKEY_CURRENT_USER\ExampleKey
ValueName: TestValue
ValueData: TestData
PsDscRunAsCredential_username: '{{ansible_user}}'
PsDscRunAsCredential_password: '{{ansible_password}}'
PsDscRunAsCredential_username: '{{ ansible_user }}'
PsDscRunAsCredential_password: '{{ ansible_password }}'
no_log: true
- name: Create file with multiple attributes
ansible.windows.win_dsc:
resource_name: File
DestinationPath: C:\ansible\dsc
Attributes: # can also be a comma separated string, e.g. 'Hidden, System'
- Hidden
- System
- Hidden
- System
Ensure: Present
Type: Directory
Expand All @@ -143,21 +143,21 @@
State: Started
PhysicalPath: C:\inetpub\wwwroot
BindingInfo: # Example of a CimInstance[] DSC parameter (list of dicts)
- Protocol: https
Port: 1234
CertificateStoreName: MY
CertificateThumbprint: C676A89018C4D5902353545343634F35E6B3A659
HostName: DSCTest
IPAddress: '*'
SSLFlags: '1'
- Protocol: http
Port: 4321
IPAddress: '*'
- Protocol: https
Port: 1234
CertificateStoreName: MY
CertificateThumbprint: C676A89018C4D5902353545343634F35E6B3A659
HostName: DSCTest
IPAddress: '*'
SSLFlags: '1'
- Protocol: http
Port: 4321
IPAddress: '*'
AuthenticationInfo: # Example of a CimInstance DSC parameter (dict)
Anonymous: no
Anonymous: false
Basic: true
Digest: false
Windows: yes
Windows: true
'''

RETURN = r'''
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/win_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
- name: Install IIS (Web-Server and Web-Common-Http)
ansible.windows.win_feature:
name:
- Web-Server
- Web-Common-Http
- Web-Server
- Web-Common-Http
state: present
- name: Install NET-Framework-Core from file
Expand Down
10 changes: 5 additions & 5 deletions plugins/modules/win_find.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@
- name: Find files in multiple paths
ansible.windows.win_find:
paths:
- C:\Temp
- D:\Temp
- C:\Temp
- D:\Temp
- name: Find files in directory while searching recursively
ansible.windows.win_find:
Expand All @@ -136,7 +136,7 @@
- name: Find files with .log and .out extension using powershell wildcards
ansible.windows.win_find:
paths: D:\Temp
patterns: [ '*.log', '*.out' ]
patterns: ['*.log', '*.out']
- name: Find files in path based on regex pattern
ansible.windows.win_find:
Expand Down Expand Up @@ -192,8 +192,8 @@
- name: Find folders/symlinks in multiple paths
ansible.windows.win_find:
paths:
- C:\Temp
- D:\Temp
- C:\Temp
- D:\Temp
file_type: directory
- name: Find files and return SHA256 checksum of files found
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/win_get_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@
dest: C:\temp\earthrise.jpg
checksum_url: http://www.example.com/sha256sum.txt
checksum_algorithm: sha256
force: True
force: true
- name: Download src with sha256 checksum url
ansible.windows.win_get_url:
url: http://www.example.com/earthrise.jpg
dest: C:\temp\earthrise.jpg
checksum: a97e6837f60cec6da4491bab387296bbcd72bdba
checksum_algorithm: sha1
force: True
force: true
'''

RETURN = r'''
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/win_optional_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
- name: Install multiple features in one task
ansible.windows.win_optional_feature:
name:
- NetFx3
- Microsoft-Windows-Subsystem-Linux
- NetFx3
- Microsoft-Windows-Subsystem-Linux
state: present
'''

Expand Down
20 changes: 10 additions & 10 deletions plugins/modules/win_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,22 +206,22 @@
path: http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe
product_id: '{CF2BEA3C-26EA-32F8-AA9B-331F7E34BA97}'
arguments:
- /install
- /passive
- /norestart
- /install
- /passive
- /norestart
- name: Install MSBuild thingy with arguments split to prevent quotes
ansible.windows.win_package:
path: https://download.visualstudio.microsoft.com/download/pr/9665567e-f580-4acd-85f2-bc94a1db745f/vs_BuildTools.exe
product_id: '{D1437F51-786A-4F57-A99C-F8E94FBA1BD8}'
arguments:
- --norestart
- --passive
- --wait
- --add
- Microsoft.Net.Component.4.6.1.TargetingPack
- --add
- Microsoft.Net.Component.4.6.TargetingPack
- --norestart
- --passive
- --wait
- --add
- Microsoft.Net.Component.4.6.1.TargetingPack
- --add
- Microsoft.Net.Component.4.6.TargetingPack
- name: Install Remote Desktop Connection Manager from msi with a permanent log
ansible.windows.win_package:
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/win_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
- name: Ensure that system32 and Powershell are present on the global system path, and in the specified order
ansible.windows.win_path:
elements:
- '%SystemRoot%\system32'
- '%SystemRoot%\system32\WindowsPowerShell\v1.0'
- '%SystemRoot%\system32'
- '%SystemRoot%\system32\WindowsPowerShell\v1.0'
- name: Ensure that C:\Program Files\MyJavaThing is not on the current user's CLASSPATH
ansible.windows.win_path:
Expand Down
9 changes: 4 additions & 5 deletions plugins/modules/win_powershell.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@
$PSVersionTable.PSVersion.Major
executable: pwsh.exe
arguments:
- -ExecutionPolicy
- ByPass
- -ExecutionPolicy
- ByPass
register: pwsh_output
failed_when:
- pwsh_output.output[0] != 7
- pwsh_output.output[0] != 7
- name: Run code in check mode
ansible.windows.win_powershell:
Expand All @@ -176,7 +176,7 @@
else {
echo 'also running in check mode'
}
check_mode: yes
check_mode: true
- name: Return a failure back to Ansible
ansible.windows.win_powershell:
Expand Down Expand Up @@ -207,7 +207,6 @@
Write-Output "Hello World!"
Write-Verbose "Hello World!"
Write-Debug "Hello World!"
'''

RETURN = r'''
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/win_regedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
ansible.windows.win_regedit:
path: HKCU:\Software\MyCompany
name: hello
data: [0xbe,0xef,0xbe,0xef,0xbe,0xef,0xbe,0xef,0xbe,0xef]
data: [0xbe, 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe, 0xef]
type: binary
- name: Add or update registry path MyCompany, with expand string entry 'hello'
Expand Down
Loading
Loading