114 lines
3 KiB
YAML
114 lines
3 KiB
YAML
---
|
|
- name: Obtain path to puppet binary using which
|
|
shell: which puppet | true
|
|
register: which_puppet
|
|
|
|
- name: Show which_puppet
|
|
debug:
|
|
msg: "{{ which_puppet }}"
|
|
|
|
- name: Obtain path to puppet binary using whereis
|
|
shell: "whereis -b puppet | awk 'BEGIN {FS=\" \"} {print($2)}'"
|
|
register: which_puppet
|
|
when: which_puppet.stdout == ""
|
|
|
|
- name: Get puppet permissions
|
|
stat:
|
|
path: "{{ which_puppet.stdout }}"
|
|
register: which_puppet_stat
|
|
|
|
- name: Set fact for puppet path
|
|
set_fact:
|
|
puppet_cmd: "{{ which_puppet.stdout }}"
|
|
when:
|
|
- which_puppet.stdout != ""
|
|
- which_puppet_stat.stat.executable
|
|
- not which_puppet_stat.stat.isdir
|
|
|
|
- name: Set fact for puppet path to estimated path when not found
|
|
set_fact:
|
|
puppet_cmd: "/usr/local/bin/puppet"
|
|
when: which_puppet.stdout == "" or not which_puppet_stat.stat.executable or which_puppet_stat.stat.isdir
|
|
|
|
- name: Obtain puppet configuration directory
|
|
shell: "{{ puppet_cmd }} config print confdir"
|
|
register: current_puppet_confdir
|
|
|
|
- name: Ensure puppet server is configured in main section
|
|
ini_file:
|
|
path: "{{ current_puppet_confdir.stdout }}/puppet.conf"
|
|
section: main
|
|
option: server
|
|
value: "{{ puppet_server }}"
|
|
backup: yes
|
|
create: yes
|
|
mode: 0644
|
|
|
|
- name: Ensure puppet server is configured in master section
|
|
ini_file:
|
|
path: "{{ current_puppet_confdir.stdout }}/puppet.conf"
|
|
section: master
|
|
option: server
|
|
value: "{{ puppet_server }}"
|
|
backup: yes
|
|
create: yes
|
|
mode: 0644
|
|
|
|
- name: Ensure puppet port is configured in main section
|
|
ini_file:
|
|
path: "{{ current_puppet_confdir.stdout }}/puppet.conf"
|
|
section: main
|
|
option: serverport
|
|
value: "{{ puppet_server_port }}"
|
|
backup: yes
|
|
create: yes
|
|
mode: 0644
|
|
|
|
- name: Ensure puppet port is configured in master section
|
|
ini_file:
|
|
path: "{{ current_puppet_confdir.stdout }}/puppet.conf"
|
|
section: master
|
|
option: port
|
|
value: "{{ puppet_server_port }}"
|
|
backup: yes
|
|
create: yes
|
|
mode: 0644
|
|
|
|
- name: Ensure puppet run interval is configured in main section
|
|
ini_file:
|
|
path: "{{ current_puppet_confdir.stdout }}/puppet.conf"
|
|
section: main
|
|
option: runinterval
|
|
value: "{{ puppet_runinterval }}"
|
|
backup: yes
|
|
create: yes
|
|
mode: 0644
|
|
|
|
- name: Ensure puppet run interval is configured in master section
|
|
ini_file:
|
|
path: "{{ current_puppet_confdir.stdout }}/puppet.conf"
|
|
section: master
|
|
option: runinterval
|
|
value: "{{ puppet_runinterval }}"
|
|
backup: yes
|
|
create: yes
|
|
mode: 0644
|
|
|
|
- name: Run puppet for the first time
|
|
shell: "{{ puppet_cmd }} agent -t"
|
|
when: run_puppet
|
|
|
|
- name: Ensure puppet agent service is enabled and started
|
|
systemd:
|
|
name: puppet
|
|
enabled: true
|
|
state: started
|
|
masked: false
|
|
when: "'WSL' not in ansible_facts['kernel']"
|
|
|
|
- name: Ensure puppet agent cron exists (WSL only)
|
|
cron:
|
|
name: puppet agent
|
|
job: puppet agent -t
|
|
minute: '30'
|
|
when: "'WSL' in ansible_facts['kernel']"
|