This commit is contained in:
willtome
2023-03-13 10:45:24 -04:00
parent b6896b3617
commit cb53962c2c
7 changed files with 216 additions and 439 deletions

View File

@@ -4,47 +4,47 @@
gather_facts: false
tasks:
- name: Set Local Admin Password
ansible.windows.win_user:
name: Administrator
password: "{{ ansible_password }}"
- name: Set Local Admin Password
ansible.windows.win_user:
name: Administrator
password: "{{ ansible_password }}"
- name: Create new domain in a new forest on the target host
ansible.windows.win_domain:
dns_domain_name: ansible.local
safe_mode_password: "{{ lookup('community.general.random_string', min_lower=1, min_upper=1, min_special=1, min_numeric=1) }}"
register: new_forest
- name: Create new domain in a new forest on the target host
ansible.windows.win_domain:
dns_domain_name: ansible.local
safe_mode_password: "{{ lookup('community.general.random_string', min_lower=1, min_upper=1, min_special=1, min_numeric=1) }}"
register: new_forest
- name: Reboot the target host
ansible.windows.win_reboot:
reboot_timeout: 3600
when: new_forest.reboot_required
- name: Reboot the target host
ansible.windows.win_reboot:
reboot_timeout: 3600
when: new_forest.reboot_required
- name: Wait up to 10min for AD web services to start
community.windows.win_wait_for_process:
process_name_exact: Microsoft.ActiveDirectory.WebServices
pre_wait_delay: 60
state: present
timeout: 600
sleep: 10
remote_user: Administrator
- name: Wait up to 10min for AD web services to start
community.windows.win_wait_for_process:
process_name_exact: Microsoft.ActiveDirectory.WebServices
pre_wait_delay: 60
state: present
timeout: 600
sleep: 10
remote_user: Administrator
- name: Create some groups
community.windows.win_domain_group:
name: "{{ item.name }}"
scope: global
loop:
- { name: "GroupA" }
- { name: "GroupB" }
- { name: "GroupC" }
- name: Create some groups
community.windows.win_domain_group:
name: "{{ item.name }}"
scope: global
loop:
- { name: "GroupA" }
- { name: "GroupB" }
- { name: "GroupC" }
- name: Create some users
community.windows.win_domain_user:
name: "{{ item.name }}"
groups: "{{ item.groups }}"
password: "{{ lookup('community.general.random_string', min_lower=1, min_upper=1, min_special=1, min_numeric=1) }}"
update_password: on_create
loop:
- { name: "UserA", groups: "GroupA" }
- { name: "UserB", groups: "GroupB" }
- { name: "UserC", groups: "GroupC" }
- name: Create some users
community.windows.win_domain_user:
name: "{{ item.name }}"
groups: "{{ item.groups }}"
password: "{{ lookup('community.general.random_string', min_lower=1, min_upper=1, min_special=1, min_numeric=1) }}"
update_password: on_create
loop:
- { name: "UserA", groups: "GroupA" }
- { name: "UserB", groups: "GroupB" }
- { name: "UserC", groups: "GroupC" }

View File

@@ -4,36 +4,36 @@
gather_facts: false
tasks:
- name: Setting host facts using complex arguments
set_fact:
temp_password: "{{ lookup('community.general.random_string', min_lower=1, min_upper=1, min_special=1, min_numeric=1) }}"
# Example result: ['&Qw2|E[-']
- name: Setting host facts using complex arguments
ansible.builtin.set_fact:
temp_password: "{{ lookup('community.general.random_string', min_lower=1, min_upper=1, min_special=1, min_numeric=1) }}"
# Example result: ['&Qw2|E[-']
- name: Create new user
community.windows.win_domain_user:
name: "{{ firstname }} {{ surname }}"
firstname: "{{ firstname }}"
surname: "{{ surname }}"
sam_account_name: "{{ firstname[0] }}{{ surname }}"
company: BobCo
password: "{{ temp_password }}"
state: present
groups:
- "GroupA"
- "GroupB"
street: "{{ street }}"
city: "{{ city }}"
state_province: IN
postal_code: "{{ postal_code }}"
country: US
attributes:
telephoneNumber: "{{ telephone_number }}"
register: new_user
- name: Create new user
community.windows.win_domain_user:
name: "{{ firstname }} {{ surname }}"
firstname: "{{ firstname }}"
surname: "{{ surname }}"
sam_account_name: "{{ firstname[0] }}{{ surname }}"
company: BobCo
password: "{{ temp_password }}"
state: present
groups:
- "GroupA"
- "GroupB"
street: "{{ street }}"
city: "{{ city }}"
state_province: IN
postal_code: "{{ postal_code }}"
country: US
attributes:
telephoneNumber: "{{ telephone_number }}"
register: new_user
- name: Display User
ansible.builtin.debug:
var: new_user
- name: Display User
ansible.builtin.debug:
var: new_user
- name: Show temp password
ansible.builtin.debug:
var: temp_password
- name: Show temp password
ansible.builtin.debug:
var: temp_password

View File

@@ -6,12 +6,12 @@
ps_script: undef
tasks:
- name: Run PowerShell
ansible.windows.win_powershell:
script: |
{{ ps_script }}
register: ps_output
- name: Run PowerShell
ansible.windows.win_powershell:
script: |
{{ ps_script }}
register: ps_output
- name: Print output
ansible.builtin.debug:
msg: "{{ ps_output.output }}"
- name: Print output
ansible.builtin.debug:
msg: "{{ ps_output.output }}"