What is matching the API action for rake task puppet:import:environments_only?

Problem: we used to do /usr/sbin/foreman-rake puppet:import:environments_only[true] in order to import just the existing environments from our puppetmaster (v5), but since foreman version 1.24 it has been removed.

I am not able to find a matching API action here Foreman :: API v2

How do you import automatically environments via API?

Thanks in advance and best regards,

**Foreman and Proxy versions:1.24.3-1

**Distribution and version:Debian GNU/Linux 9.13 (stretch)

You’re looking for the environments API and in particular import_puppetclasses on a Smart Proxy. You must find out the Smart Proxy ID and loop over the existing environments.

1 Like

It says import_puppetclasses. That is actually not my goal. I just want to import environments.

I did -X POST https://foreman/api/environments/601/smart_proxies/1/import_puppetclasses and I am getting

Failed to update the environments and Puppet classes from the on-disk puppet installation: Validation failed: Puppetclass lookup key has already been taken

Our environments are created on the puppetserver in the /etc/puppetlabs/code/environments/ directory.
With GET /api/environments, I still only see older environments from the time while working with foreman 1.21, but not after.
The new environments do not show up.

I was meant to say: we create our environments on the puppetserver in the /etc/puppetlabs/code/environments/ directory not with foreman, rather during our work process via git branches.