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

Updates to allow AWX and Ansible Tower to be used #121

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0c8b09a
Update cpm_registration.yml
bab29 Jun 4, 2021
f9bf664
Update cpm_registration.yml
bab29 Jun 4, 2021
665f574
Update cpm_registration.yml
bab29 Jun 4, 2021
865c650
Update cpm_registration.yml
bab29 Jun 5, 2021
9ae1e9e
Update cpm_validateparameters.yml
bab29 Jun 5, 2021
e4b780b
Update cpm_validateparameters.yml
bab29 Jun 5, 2021
329935e
Update cpm_validateparameters.yml
bab29 Jun 5, 2021
9cb2022
Update cpm_validateparameters.yml
bab29 Jun 5, 2021
0a66891
Update cpm_validateparameters.yml
bab29 Jun 5, 2021
0d70b01
Update cpm_validateparameters.yml
bab29 Jun 5, 2021
3c64e05
Update cpm_validateparameters.yml
bab29 Jun 5, 2021
274dced
Update cpm_validateparameters.yml
bab29 Jun 5, 2021
1769ef1
Update cpm_validateparameters.yml
bab29 Jun 5, 2021
6c08938
Update cpm_validateparameters.yml
bab29 Jun 5, 2021
e4ab88a
Update cpm_validateparameters.yml
bab29 Jun 24, 2021
c12bc98
Update cpm_validateparameters.yml
bab29 Jun 24, 2021
ad68d6f
Update cpm_validateparameters.yml
bab29 Jun 24, 2021
a208b6c
Update cpm_validateparameters.yml
bab29 Jun 24, 2021
0253e70
Update cpm_registration.yml
bab29 Jun 24, 2021
6b819c5
Update cpm_extract.yml
bab29 Jun 30, 2021
167b7a5
Update cpm_extract.yml
bab29 Jun 30, 2021
60bd18f
Merge branch 'cyberark:master' into master
bab29 Jul 29, 2021
deb8f76
Updates to actions
bab29 Mar 12, 2022
85cd237
update community.windows.win_unzip
bab29 Mar 12, 2022
bd37537
update setup
bab29 Mar 12, 2022
565b21a
community.windows.win_lineinfile
bab29 Mar 12, 2022
811966a
ansible.builtin.
bab29 Mar 12, 2022
b81661b
community.windows.win_xml
bab29 Mar 14, 2022
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
18 changes: 9 additions & 9 deletions tasks/cpm_clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@
# tasks file for cpm_extract

- name: Find all inf files
win_find:
ansible.windows.win_find:
paths: "{{ cpm_installation_path }}\\Password Manager\\Logs"
patterns: ['*.*']
register: files_to_delete

- name: Delete all inf files
win_file:
ansible.windows.win_file:
path: "{{ item.path }}"
state: absent
with_items: "{{ files_to_delete.files }}"

- name: Clean Windows\\Temp folder
win_find:
ansible.windows.win_find:
paths: "C:\\Windows\\Temp"
patterns: ['CPM*.*', 'InstallationAutomation*.*']
register: files_to_delete

- name: Delete temp folder
win_file:
ansible.windows.win_file:
path: "{{ item.path }}"
state: absent
with_items: "{{ files_to_delete.files }}"

- name: Keep installation automation folder
win_copy:
ansible.windows.win_copy:
src: "{{ cpm_installationautomation_folder }}"
dest: "{{ cpm_base_bin_drive }}\\Cyberark\\CPM"
remote_src: True
ignore_errors: yes

- name: Delete extract folder
win_file:
ansible.windows.win_file:
path: "{{ cpm_extract_folder }}"
state: absent

- name: Clean run History
win_shell: |
ansible.windows.win_shell: |
try {
$path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU"

Expand All @@ -59,7 +59,7 @@
exit 0

- name: Clean event logs
win_shell: |
ansible.windows.win_shell: |
try {
wevtutil el | ForEach-Object { wevtutil cl "$_" }
} catch {
Expand All @@ -68,7 +68,7 @@
}

- name: Clean recycle bin
win_shell: |
ansible.windows.win_shell: |
try {
$Recycler = (New-Object -ComObject Shell.Application).Namespace(0xa)
$Recycler.items() | ForEach-Object { rm $_.path -Force -Recurse }
Expand Down
15 changes: 8 additions & 7 deletions tasks/cpm_extract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,42 @@
# tasks file for cpm_extract

- name: Create folder
win_file:
ansible.windows.win_file:
path: "{{ cpm_extract_folder }}"
state: directory

- name: Copy CPM package from local source
win_copy:
ansible.windows.win_copy:
src: "{{ cpm_zip_file_path }}"
dest: "{{ cpm_extract_folder }}\\{{ cpm_artifact_name }}"
remote_src: "{{cpm_zip_file_unc}}"
register: st

- fail:
- ansible.builtin.fail:
msg: "{{ cpm_zip_file_path }} not exists, failing..."
when: not st.checksum

- name: Check if package is valid using checksum
fail:
ansible.builtin.fail:
msg: "Checksum does not match, please validate your package."
when:
- st.checksum != cpm_sha1_checksum
- not cpm_ignore_checksum

- name: Unzip the CPM package
win_unzip:
community.windows.win_unzip:
src: "{{ cpm_extract_folder }}\\{{ cpm_artifact_name }}"
dest: "{{ cpm_extract_folder }}"
when: cpm_official

- name: Create component folder
win_file:
ansible.windows.win_file:
path: "{{ cpm_extract_folder }}\\{{ cpm_component_folder }}"
state: directory
when: not cpm_official

- name: Unzip the CPM package
win_unzip:
community.windows.win_unzip:
src: "{{ cpm_extract_folder }}\\{{ cpm_artifact_name }}"
dest: "{{ cpm_extract_folder }}\\{{ cpm_component_folder }}"
when: not cpm_official
12 changes: 6 additions & 6 deletions tasks/cpm_hardening.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
# tasks file for cpm_hardening

- name: Create user.ini file
win_file:
ansible.windows.win_file:
path: "{{ cpm_installation_path }}\\Password Manager\\Vault\\user.ini"
state: touch

- name: Hardening Block
block:

- name: Set cpm_hardening_script in domain
set_fact:
ansible.builtin.set_fact:
cpm_hardening_script: "CPM_In_Domain_Hardening.ps1"
when: ansible_windows_domain_member

- name: Run CPM hardening
win_shell: |
ansible.windows.win_shell: |
$ErrorActionPreference = "SilentlyContinue"
try {
$Action = .\{{ cpm_hardening_script }}
Expand All @@ -35,17 +35,17 @@
chdir: "{{ cpm_installationautomation_folder }}"

- name: Validate CPM hardening and stop service
win_service:
ansible.windows.win_service:
name: "{{ cpm_service_name }}"
state: stopped
register: cpm_service_info

- name: Validate CPM scanner hardening and stop service
win_service:
ansible.windows.win_service:
name: "{{ cpm_scanner_service_name }}"
state: stopped
register: cpm_scanner_service_info

- set_fact:
- ansible.builtin.set_fact:
cpm_hardened: true
when: cpm_service_info.username != "LocalSystem" and cpm_scanner_service_info.username != "LocalSystem"
24 changes: 12 additions & 12 deletions tasks/cpm_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# tasks file for cpm installation

- name: Set installation folder on xml config file
win_shell: |
ansible.windows.win_shell: |
try
{
### This script set the install directory received from var in the install config file
Expand All @@ -23,7 +23,7 @@
block:

- name: Run CPM installation
win_shell: |
ansible.windows.win_shell: |
Set-Location "{{ cpm_installationautomation_folder }}\Installation"
#$ErrorActionPreference = "SilentlyContinue"
$Action = .\CPMInstallation.ps1
Expand All @@ -38,13 +38,13 @@
chdir: "{{ cpm_installationautomation_folder }}\\Installation"

- name: Get log path for installation
win_shell: |
ansible.windows.win_shell: |
$Result = Get-Content "{{ cpm_install_log }}"
Write-Output $Result
register: log_result

- name: Fetch installation log from path
fetch:
ansible.builtin.fetch:
src: '{{ item.logPath }}'
dest: '{{ lookup("config", "DEFAULT_LOG_PATH") | dirname }}/cpm/{{ inventory_hostname }}_install.log'
flat: yes
Expand All @@ -54,31 +54,31 @@
rescue:

- name: Rescue - Get log path for installation
win_shell: |
ansible.windows.win_shell: |
$Result = Get-Content "{{ cpm_install_log }}"
Write-Output $Result
register: log_result

- name: Rescue - Fetch installation log from path
fetch:
ansible.builtin.fetch:
src: '{{ item.logPath }}'
dest: '{{ lookup("config", "DEFAULT_LOG_PATH") | dirname }}/cpm/{{ inventory_hostname }}_install.log'
flat: yes
with_items:
- "{{ log_result.stdout | from_json }}"

- name: Rescue - Fail installation stage
fail:
ansible.builtin.fail:
msg: 'ERROR: Installation failed. For more info check {{ lookup("config", "DEFAULT_LOG_PATH") | dirname }}/cpm/{{ inventory_hostname }}_install.log'

- name: Get log path for installation
win_shell: |
ansible.windows.win_shell: |
$Result = Get-Content "{{ cpm_install_log }}"
Write-Output $Result
register: log_result

- name: Validate CPM installation
win_lineinfile:
community.windows.win_lineinfile:
path: '{{ item.logPath }}'
regexp: 'Operation Succeeded'
state: present
Expand All @@ -87,15 +87,15 @@
- "{{ log_result.stdout | from_json }}"

- name: Check if CPM service created successfully
win_service:
ansible.windows.win_service:
name: "{{ cpm_service_name }}"
register: cpm_service_info

- name: Check if CPM scanner created successfully
win_service:
ansible.windows.win_service:
name: "{{ cpm_scanner_service_name }}"
register: cpm_scanner_service_info

- set_fact:
- ansible.builtin.set_fact:
cpm_exists: "{{ cpm_service_info.exists }}"
cpm_scanner_exists: "{{ cpm_scanner_service_info.exists }}"
12 changes: 6 additions & 6 deletions tasks/cpm_prerequisites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
block:

- name: Run CPM prerequisites
win_shell: |
ansible.windows.win_shell: |
$ErrorActionPreference = "SilentlyContinue"
$Action = .\CPM_PreInstallation.ps1
$Action | Out-File -FilePath "{{ cpm_prerequisites_log }}"
Expand All @@ -19,13 +19,13 @@
chdir: "{{ cpm_installationautomation_folder }}"

- name: Get log path for prerequisites
win_shell: |
ansible.windows.win_shell: |
$Result = Get-Content "{{ cpm_prerequisites_log }}"
Write-Output $Result
register: log_result

- name: Fetch prerequisites log from path
fetch:
ansible.builtin.fetch:
src: '{{ item.logPath }}'
dest: '{{ lookup("config", "DEFAULT_LOG_PATH") | dirname }}/cpm/{{ inventory_hostname }}_prerequisites.log'
flat: yes
Expand All @@ -35,19 +35,19 @@
rescue:

- name: Rescue - Get log path for prerequisites
win_shell: |
ansible.windows.win_shell: |
$Result = Get-Content "{{ cpm_prerequisites_log }}"
Write-Output $Result
register: log_result

- name: Rescue - Fetch prerequisites log from path
fetch:
ansible.builtin.fetch:
src: '{{ item.logPath }}'
dest: '{{ lookup("config", "DEFAULT_LOG_PATH") | dirname }}/cpm/{{ inventory_hostname }}_prerequisites.log'
flat: yes
with_items:
- "{{ log_result.stdout | from_json }}"

- name: Rescue - Fail prerequisites stage
fail:
ansible.builtin.fail:
msg: 'ERROR: Pre Prerequisites failed. For more info check {{ lookup("config", "DEFAULT_LOG_PATH") | dirname }}/cpm/{{ inventory_hostname }}_prerequisites.log'
Loading