summaryrefslogtreecommitdiff
path: root/ansible/main.yaml
blob: 3c0effee46b4ad7631804c1a778b45c3ef3822e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
- name: deploy active directory range on proxmox
  hosts: localhost
  gather_facts: no
  tasks:
    - name: deploy main domain controller vm on proxmox
      include_role:
        name: proxmox_vm
      vars:
        os_type: "windows"
        template: "{{ windows_server_template_name }}"
        id: "{{ windows_server_template_id }}"
        vm: "{{ main_dc01_hostname }}"
        newid: "{{ main_dc01_vmid }}"
        vmid: "{{ main_dc01_vmid }}"
        ip: "{{ main_dc01_ip_address }}"
        gateway: "{{ network_gateway }}"
        dns: "8.8.8.8"
        hostname: "{{ main_dc01_hostname }}"
        domain: "{{ main_domain_name }}"
        fqdn: "{{ main_dc01_hostname }}.{{ main_domain_name }}"
    
    - name: add domain controller vm to in-memory inventory
      add_host:
        name: "{{ main_dc01_hostname }}.{{ main_domain_name }}"
        ansible_host: "{{ main_dc01_ip_address }}"
        ansible_connection: "{{ win_connector }}"
        ansible_user: "{{ default_win_username }}"
        ansible_password: "{{ default_win_password }}"
        ansible_port: "{{ win_port }}"
        ansible_winrm_transport: basic
        ansible_winrm_server_cert_validation: ignore
      changed_when: false
    
    - name: deploy linux domain vm on proxmox
      include_role:
        name: proxmox_vm
      vars:
        os_type: "linux"
        template: "{{ linux_server_template_name }}"
        id: "{{ linux_server_template_id }}"
        vm: "{{ main_linux_srv01_hostname }}"
        newid: "{{ main_linux_srv01_vmid }}"
        vmid: "{{ main_linux_srv01_vmid }}"
        ip: "{{ main_linux_srv01_ip_address }}"
        gateway: "{{ network_gateway }}"
        dns: "{{ main_dc01_ip_address }}"
        hostname: "{{ main_linux_srv01_hostname }}"
        domain: "{{ main_domain_name }}"
        fqdn: "{{ main_linux_srv01_hostname }}.{{ main_domain_name }}"

    - name: add linux domain vm to in-memory inventory
      add_host:
        name: "{{ main_linux_srv01_hostname }}.{{ main_domain_name }}"
        ansible_host: "{{ main_linux_srv01_ip_address }}"
        ansible_connection: "{{ linux_connector }}"
        ansible_user: "{{ default_linux_username }}"
        ansible_password: "{{ default_linux_password }}"
        ansible_port: "{{ linux_port }}"
        ansible_host_key_checking: false
      changed_when: false

- name: configure everything
  hosts: all
  gather_facts: no
  tasks:
    - name: configure windows dc
      include_role:
        name: dc01
      when: inventory_hostname == main_dc01_hostname + '.' + main_domain_name

    - name: configure linux server
      include_role:
        name: srv01
      when: inventory_hostname == main_linux_srv01_hostname + '.' + main_domain_name