From a4e1c86595608cb659449e8843023d341ca07afd Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Wed, 10 Sep 2014 13:46:17 -0700 Subject: [PATCH] Make ansible speak to appropriate puppetmaster With split puppet master infrastructure ansible needs to be told which puppetmaster to talk to. Do this by making puppetmaster a required argument to the puppet ansible playbook. Since we can't rely on the cert listing while this is happening also add puppet master specific host list files which can be used to specify which hosts talk to which puppetmaster via the new ansible playbook feature. Change-Id: I412c2bd6cb390d00d1b9d0e4630e75776edabbb9 --- files/library/config_management/puppet | 5 ++++- manifests/init.pp | 9 +++++++-- files/ansible.cfg => templates/ansible.cfg.erb | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) rename files/ansible.cfg => templates/ansible.cfg.erb (68%) diff --git a/files/library/config_management/puppet b/files/library/config_management/puppet index 763454b..0b429c4 100644 --- a/files/library/config_management/puppet +++ b/files/library/config_management/puppet @@ -53,6 +53,7 @@ def main(): module = AnsibleModule( argument_spec=dict( timeout=dict(default="30m"), + puppetmaster=dict(required=True), show_diff=dict( default=False, aliases=['show-diff'], type='bool'), ), @@ -67,9 +68,11 @@ def main(): msg="Could not find puppet. Please ensure it is installed.") cmd = ("timeout -s 9 %(timeout)s %(puppet_cmd)s agent --onetime" + " --server %(puppetmaster)s" " --ignorecache --no-daemonize --no-usecacheonfailure --no-splay" " --detailed-exitcodes --verbose") % dict( - timeout=pipes.quote(p['timeout']), puppet_cmd=PUPPET_CMD) + timeout=pipes.quote(p['timeout']), puppet_cmd=PUPPET_CMD, + puppetmaster=pipes.quote(p['puppetmaster'])) if p['show_diff']: cmd += " --show-diff" rc, stdout, stderr = module.run_command(cmd) diff --git a/manifests/init.pp b/manifests/init.pp index 409bf57..fea6db3 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,6 +1,8 @@ # == Class: ansible # -class ansible { +class ansible ( + $ansible_hostfile = '/usr/local/bin/puppet-inventory' +) { include logrotate include pip @@ -18,7 +20,10 @@ class ansible { file { '/etc/ansible/ansible.cfg': ensure => present, - source => 'puppet:///modules/ansible/ansible.cfg', + mode => '0644', + owner => 'root', + group => 'root', + content => template('ansible/ansible.cfg.erb'), require => File['/etc/ansible'], } diff --git a/files/ansible.cfg b/templates/ansible.cfg.erb similarity index 68% rename from files/ansible.cfg rename to templates/ansible.cfg.erb index 1f0319c..94fd27c 100644 --- a/files/ansible.cfg +++ b/templates/ansible.cfg.erb @@ -1,4 +1,4 @@ [defaults] -hostfile=/usr/local/bin/puppet-inventory +hostfile=<%= @ansible_hostfile %> library=/usr/share/ansible:/etc/ansible/library log_path=/var/log/ansible.log