To answer my own question ...

/usr/sbin/foreman-rake puppet:import:puppet_classes[false,master]

... seems to work. The two parameters are batch and envname. The task 
imports the environment (= Git branch) "master" in non-batch mode (i.e. a 
blocking call).

Note that I'm not a Ruby developer, I'm basically guessing. Neither do I 
know Foreman well. Just reading and interpreting the code at 
https://github.com/theforeman/foreman/blob/develop/lib/tasks/puppet.rake#L44-L129

   1. Any Foreman wizard here to confirm my findings?
   2. Is there a way to parametrize the call in 
   /etc/puppetlabs/r10k/r10k.yaml? (The webhook I'm calling to run r10k is 
   passed the "master" parameter already, for example. Can I pass this on to 
   the call somehow?)
   
Peter


Am Donnerstag, 1. Juni 2017 11:46:31 UTC+2 schrieb Peter Bittner:
>
> Hi there,
>
> I've successfully managed to set up a Foreman host, a Puppet control 
> repository and r10k on the Foreman host to pull changes from the repo 
> whenever they are made (and merged into the main branch). Hence, Puppet 
> environments are deployed automatically to the host. This is done by r10k, 
> triggered by a webhook, and r10k also has a `postrun` hook configured that 
> is supposed to tell Foreman that changes were just pulled and integrated.
>
> What's still missing is to automatic updating / importing of Puppet 
> environments in Foreman. Instead of going to *Configure* > *Environments* 
> and klicking on the "Import environments from $hostname" button in the 
> Foreman UI I want to have this happen automatically whenever changes are 
> deployed by r10k -- that's what the `postrun` hook is good for.
>
> The command I run in the hook is:
>
> /usr/sbin/foreman-rake puppet:import:puppet_classes[batch]
>
> According to the Foreman source code this task updates both all 
> environments and classes. 
> https://github.com/theforeman/foreman/blob/develop/lib/tasks/puppet.rake#L45-L46
>
> Interestingly, despite some output on the console there is no change 
> visible in The Foreman. The list of environments remains unchanged (one 
> "production" entry only, just as originally installed). The output of the 
> command is as follows:
>
> $ sudo /usr/sbin/foreman-rake puppet:import:puppet_classes[batch]'     
> Successfully encrypted field for Setting::Auth oauth_consumer_key
> Successfully decrypted field for Setting::Auth oauth_consumer_key
> Successfully decrypted field for Setting::Auth oauth_consumer_key
> Successfully encrypted field for Setting::Auth oauth_consumer_secret
> Successfully decrypted field for Setting::Auth oauth_consumer_secret
> Successfully decrypted field for Setting::Auth oauth_consumer_secret
>
> Any idea what's wrong? Why doesn't this command result in and update in 
> The Foreman? Or is there a more suitable command?
>
> Thanks for any hints,
> Peter
>

-- 
You received this message because you are subscribed to the Google Groups 
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to