-
Notifications
You must be signed in to change notification settings - Fork 6
/
sagenv-sysprep-webmethods.yaml
86 lines (80 loc) · 2.75 KB
/
sagenv-sysprep-webmethods.yaml
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
76
77
78
79
80
81
82
83
84
85
86
---
- name: Load vars
hosts: "*"
vars:
default_var_files:
- "./vars/base_sysprep.yaml"
- "~/.custom_sysprep.yaml"
tasks:
- name: Build a list of all the files to load.
set_fact:
all_var_files: "{{ default_var_files + (include_var_files | default([]) ) }}"
- name: Print the var files to include
debug:
msg: "Var file to load in order: {{ all_var_files | join(',') }}"
- name: Include vars
include_vars:
file: "{{ item }}"
with_fileglob: "{{ all_var_files }}"
ignore_errors: yes
tags:
- always
## create the wM user with the right SSH key on command central
- hosts: "{{ cce_provisioning_command_central_hosts | default('commandcentral') }}"
become: true
tasks:
- import_role:
name: create-service-user
vars:
username: "{{ webmethods_user }}"
userid: "{{ webmethods_userid }}"
groupname: "{{ webmethods_group }}"
groupid: "{{ webmethods_groupid }}"
generate_ssh_key: yes
- name: Print user output
debug: var=created_user
- name: write public key to local file
copy:
content: "{{ created_user.ssh_public_key }}"
dest: "/tmp/created_user_ssh_public_key_{{inventory_hostname}}"
delegate_to: localhost
tags:
- sysprep
- sysprep_webmethods
## then create the wM user on all the webmethods server using the public key of the key created above
- hosts: "{{ inventory_groupnames }}"
become: true
roles:
- role: create-service-user
vars:
username: "{{ webmethods_user }}"
userid: "{{ webmethods_userid }}"
groupname: "{{ webmethods_group }}"
groupid: "{{ webmethods_groupid }}"
authorized_sshkey_path: "/tmp/created_user_ssh_public_key_*"
- role: prepare-wminstall
tasks:
- name: Add command central DNS into /etc/hosts to make sure it can connect back to it using aliases
lineinfile:
dest: /etc/hosts
regexp: '.*{{ item }}$'
line: "{{ hostvars[item]['ip'] }} {{ hostvars[item]['hostname'] }} {{ hostvars[item]['fqdn'] }} {{ item }}"
state: present
when: hostvars[item]['ip'] is defined and hostvars[item]['hostname'] is defined and hostvars[item]['fqdn'] is defined
with_items:
- "{{ groups['commandcentral'] }}"
tags:
- sysprep
- sysprep_webmethods
- hosts: localhost
become: true
tasks:
- name: clear the pub ssh keys
file:
path: "{{ item }}"
state: absent
with_fileglob:
- "/tmp/created_user_ssh_public_key_*"
tags:
- sysprep
- sysprep_webmethods