Created
September 23, 2022 02:28
-
-
Save ardichoke/699f0ed5c9fc08295dee8a710b6f999c to your computer and use it in GitHub Desktop.
Puppet Agent Bootstrap Ansible Playbook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Bootstrap Puppet | |
hosts: all | |
become: yes | |
become_user: root | |
tasks: | |
- set_fact: | |
puppet_bin: "{{ '/usr/local/bin/puppet' if ( ansible_facts['architecture'] is regex('^arm') ) else '/opt/puppetlabs/bin/puppet' }}" | |
- name: Debian ARM Setup | |
block: | |
- name: Install ruby | |
package: | |
name: ruby-full | |
state: present | |
- name: Install puppet | |
gem: | |
name: puppet | |
user_install: no | |
- name: Install core modules | |
loop: | |
- augeas_core | |
- host_core | |
- scheduled_task | |
- sshkeys_core | |
- zfs_core | |
- cron_core | |
- mount_core | |
- selinux_core | |
- yumrepo_core | |
- zone_core | |
command: | |
cmd: /usr/local/bin/puppet module install --target-dir /opt/puppetlabs/puppet/vendor_modules "puppetlabs/{{ item }}" | |
creates: /opt/puppetlabs/puppet/vendor_modules/{{ item }}/metadata.json | |
when: ansible_facts['architecture'] is regex("^arm") | |
- name: Debian Repo Setup (x86_64) | |
block: | |
- name: Add Repo (Debian) | |
apt: | |
deb: "http://apt.puppet.com/puppet7-release-{{ ansible_distribution_release }}.deb" | |
- name: Update Apt Cache | |
apt: | |
update_cache: yes | |
when: ansible_facts['os_family'] == 'Debian' and ansible_facts['architecture'] == "x86_64" | |
- name: RHEL Repo Setup | |
block: | |
- name: Add Repo (RHEL) | |
yum: | |
name: "https://yum.puppetlabs.com/puppet7-release-el-{{ ansible_distribution_major_version }}.noarch.rpm" | |
state: present | |
when: ansible_facts['os_family'] == 'RedHat' | |
- name: Install Puppet Agent package (x86_64) | |
when: ansible_facts['architecture'] == "x86_64" | |
package: | |
name: puppet-agent | |
state: present | |
- name: Run Puppet | |
command: "{{ puppet_bin }} agent -t -w 60 --server puppet.ardchk.me" | |
register: pup_out | |
failed_when: pup_out.rc == 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment