Skip to content

Instantly share code, notes, and snippets.

@guruevi
Last active September 20, 2024 20:37
Show Gist options
  • Select an option

  • Save guruevi/01ccf6ddc85d8c09a00a8c0b0f46db85 to your computer and use it in GitHub Desktop.

Select an option

Save guruevi/01ccf6ddc85d8c09a00a8c0b0f46db85 to your computer and use it in GitHub Desktop.

Revisions

  1. guruevi revised this gist Feb 17, 2024. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion setup_psrp.yml
    Original file line number Diff line number Diff line change
    @@ -23,4 +23,9 @@
    changed_when: false

    - name: Gathering facts
    setup:
    setup:

    post_tasks:
    - name: Reset ExecutionPolicy
    ansible.windows.win_powershell:
    script: Set-ExecutionPolicy Undefined -Scope LocalMachine -Force
  2. guruevi revised this gist Feb 17, 2024. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions setup_psrp.yml
    Original file line number Diff line number Diff line change
    @@ -22,5 +22,5 @@
    delegate_to: localhost
    changed_when: false

    - name: Gathering facts
    setup:
    - name: Gathering facts
    setup:
  3. guruevi created this gist Feb 17, 2024.
    26 changes: 26 additions & 0 deletions setup_psrp.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    - name: Setup Windows machine with Ansible
    hosts: all
    gather_facts: false

    pre_tasks:
    - name: Setup WinRM, PSRP
    community.windows.psexec:
    hostname: '{{ hostvars[inventory_hostname]["ansible_host"] | default(inventory_hostname) }}'
    connection_username: '{{ ansible_user }}'
    connection_password: '{{ ansible_password }}'
    encrypt: yes
    executable: powershell.exe
    arguments: '-'
    stdin: |
    Set-ExecutionPolicy Bypass -Scope LocalMachine -Force
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    $url = "https://raw.githubusercontent.com/ansible/ansible-documentation/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"
    $file = "$env:temp\ConfigureRemotingForAnsible.ps1"
    (New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file)
    Invoke-Expression "$file -SkipNetworkProfileCheck"
    exit
    delegate_to: localhost
    changed_when: false

    - name: Gathering facts
    setup: