Hi,
I've been working on a project for a completely automated setup of Foreman,
this includes subnets, dns-zones, etc. I will not bore you with the details
but i've got this pretty much setup and it works. The company I'm doing
this project for uses configuration files that describe what hosts should
be setup with what details. I've created a converter for these files that
enables me to import this data using the REST API. This again works well no
troubles. Now this is basically the initial setup, after the import is done
I do not want to use these old configuration files but something structured
for example in JSON. So I was thinking of writing a script that extracts
all the (JSON) data that I want to a file. Than it needs to be possible to
reinstall the Foreman server and import the file again using a script.
After the import is done I should basically be able to deploy nodes again
as if nothing happened. For now the JSON file should include an
organization, multiple locations, multiple hostgroup, multiple subnets, one
or more domains, the hosts and all the parameters defined in Foreman.
Everything will be linked to a organization.Than my questions:
- Is setting up on or more scripts for this a viable way for doing this?
- Is there more efficient way of doing this (maybe this is easier using
the hammer cli or just extracting it out of the database)?
- Is there anybody out there already doing something similar, if so how?
- Are there people interested in a setup like this?
I would assume Foreman being written in ruby that this would be the best
language to do it in. Unfortunately I'm not very proficient in ruby and
will most likely do this in either python or PHP.
There is a project to export and import via CSV files, hammer-cli-csv[1].
Your contributions there, or just feedback, is welcome.
The foreman resources are not well covered or tested, but includes at least
initial support for the list below. Some but not all plugins are included,
such as remote execution's job templates.
activation_keys
architectures
compute_profiles
compute_resources
containers
content_hosts
content_views
content_view_filters
domains
export
host_collections
hosts
host_groups
import
installation_media
job_templates
lifecycle_environments
locations
operating_systems
organizations
partition_tables
products
provisioning_templates
puppet_environments
puppet_facts
puppet_reports
reports
roles
settings
smart_proxies
splice
subnets
subscriptions
sync_plans
users
[1] https://github.com/Katello/hammer-cli-csv
···
On Mon, Aug 15, 2016 at 6:11 AM, Maurice Mouw wrote:
Hi,
I’ve been working on a project for a completely automated setup of
Foreman, this includes subnets, dns-zones, etc. I will not bore you with
the details but i’ve got this pretty much setup and it works. The company
I’m doing this project for uses configuration files that describe what
hosts should be setup with what details. I’ve created a converter for these
files that enables me to import this data using the REST API. This again
works well no troubles. Now this is basically the initial setup, after the
import is done I do not want to use these old configuration files but
something structured for example in JSON. So I was thinking of writing a
script that extracts all the (JSON) data that I want to a file. Than it
needs to be possible to reinstall the Foreman server and import the file
again using a script. After the import is done I should basically be able
to deploy nodes again as if nothing happened. For now the JSON file should
include an organization, multiple locations, multiple hostgroup, multiple
subnets, one or more domains, the hosts and all the parameters defined in
Foreman. Everything will be linked to a organization.Than my questions:
- Is setting up on or more scripts for this a viable way for doing
this?
- Is there more efficient way of doing this (maybe this is easier
using the hammer cli or just extracting it out of the database)?
- Is there anybody out there already doing something similar, if so
how?
- Are there people interested in a setup like this?
I would assume Foreman being written in ruby that this would be the best
language to do it in. Unfortunately I’m not very proficient in ruby and
will most likely do this in either python or PHP.
–
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 foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.
Maurice, we have this too - I posted here originally (and some time ago!)
Our script(s):
- create lifecycles / locations / settings etc
- enable / sync RH repos
- create / sync custom repos (and add urls)
- create gpg keys
- create and assign sync plans
- create content view, publish version 1 and promote to all lifecycles
- create activation keys, assign subscriptions
- create / upload provisioning templates, partition tables etc
- creates hostgroups, assigns OSs to them
- allows for provisioning template lifecycle overrides per host groups etc
- sets parameters throughout
It's all heavily structured (and we nest a lot) and the input file is a big
chunk of yaml. The api scripts are written in (bad) ruby - I'm not really a
programmer! - started originally RH professional services.
···
On Monday, August 15, 2016 at 6:12:35 AM UTC-4, Maurice Mouw wrote:
>
> Hi,
>
> I've been working on a project for a completely automated setup of
> Foreman, this includes subnets, dns-zones, etc. I will not bore you with
> the details but i've got this pretty much setup and it works. The company
> I'm doing this project for uses configuration files that describe what
> hosts should be setup with what details. I've created a converter for these
> files that enables me to import this data using the REST API. This again
> works well no troubles. Now this is basically the initial setup, after the
> import is done I do not want to use these old configuration files but
> something structured for example in JSON. So I was thinking of writing a
> script that extracts all the (JSON) data that I want to a file. Than it
> needs to be possible to reinstall the Foreman server and import the file
> again using a script. After the import is done I should basically be able
> to deploy nodes again as if nothing happened. For now the JSON file should
> include an organization, multiple locations, multiple hostgroup, multiple
> subnets, one or more domains, the hosts and all the parameters defined in
> Foreman. Everything will be linked to a organization.Than my questions:
>
>
> - Is setting up on or more scripts for this a viable way for doing
> this?
> - Is there more efficient way of doing this (maybe this is easier
> using the hammer cli or just extracting it out of the database)?
> - Is there anybody out there already doing something similar, if so
> how?
> - Are there people interested in a setup like this?
>
> I would assume Foreman being written in ruby that this would be the best
> language to do it in. Unfortunately I'm not very proficient in ruby and
> will most likely do this in either python or PHP.
>
I would +1 for the idea of using the CSV tools to upload a configuration.
I have tried to use the CSV files to rebuild a configuration from
scratch and it kind of works but needs some work to fill out the corner
cases.
The upside of using the CSV import is that it will be part of the code
base and should see fixes as the code changes over time.
It should be possible to build a generator to take your client
configuration and generate a set of CSV files.
Once you have the CSV files you can then run them against the hammer
interface and you have a fully configured system.
···
On 08/15/2016 08:21 AM, Tom McKay wrote:
> There is a project to export and import via CSV files,
> hammer-cli-csv[1]. Your contributions there, or just feedback, is welcome.
>
> The foreman resources are not well covered or tested, but includes at
> least initial support for the list below. Some but not all plugins are
> included, such as remote execution's job templates.
>
> activation_keys
> architectures
> compute_profiles
> compute_resources
> containers
> content_hosts
> content_views
> content_view_filters
> domains
> export
> host_collections
> hosts
> host_groups
> import
> installation_media
> job_templates
> lifecycle_environments
> locations
> operating_systems
> organizations
> partition_tables
> products
> provisioning_templates
> puppet_environments
> puppet_facts
> puppet_reports
> reports
> roles
> settings
> smart_proxies
> splice
> subnets
> subscriptions
> sync_plans
> users
>
> [1] https://github.com/Katello/hammer-cli-csv
>
> On Mon, Aug 15, 2016 at 6:11 AM, Maurice Mouw > wrote:
>
> Hi,
>
> I've been working on a project for a completely automated setup of
> Foreman, this includes subnets, dns-zones, etc. I will not bore
> you with the details but i've got this pretty much setup and it
> works. The company I'm doing this project for uses configuration
> files that describe what hosts should be setup with what details.
> I've created a converter for these files that enables me to import
> this data using the REST API. This again works well no troubles.
> Now this is basically the initial setup, after the import is done
> I do not want to use these old configuration files but something
> structured for example in JSON. So I was thinking of writing a
> script that extracts all the (JSON) data that I want to a file.
> Than it needs to be possible to reinstall the Foreman server and
> import the file again using a script. After the import is done I
> should basically be able to deploy nodes again as if nothing
> happened. For now the JSON file should include an organization,
> multiple locations, multiple hostgroup, multiple subnets, one or
> more domains, the hosts and all the parameters defined in Foreman.
> Everything will be linked to a organization.Than my questions:
>
> * Is setting up on or more scripts for this a viable way for
> doing this?
> * Is there more efficient way of doing this (maybe this is
> easier using the hammer cli or just extracting it out of the
> database)?
> * Is there anybody out there already doing something similar, if
> so how?
> * Are there people interested in a setup like this?
>
> I would assume Foreman being written in ruby that this would be
> the best language to do it in. Unfortunately I'm not very
> proficient in ruby and will most likely do this in either python
> or PHP.
> --
> 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 foreman-users+unsubscribe@googlegroups.com
> .
> To post to this group, send email to
> foreman-users@googlegroups.com
> .
> Visit this group at https://groups.google.com/group/foreman-users
> .
> For more options, visit https://groups.google.com/d/optout
> .
>
>
> --
> 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 foreman-users+unsubscribe@googlegroups.com
> .
> To post to this group, send email to foreman-users@googlegroups.com
> .
> Visit this group at https://groups.google.com/group/foreman-users.
> For more options, visit https://groups.google.com/d/optout.
–
Alvin Starr || voice: (905)513-7688
Netvel Inc. || Cell: (416)806-0133
alvin@netvel.net ||
Hi there
> I would +1 for the idea of using the CSV tools to upload a configuration.
>
> I have tried to use the CSV files to rebuild a configuration from
> scratch and it kind of works but needs some work to fill out the corner
> cases.
>
> The upside of using the CSV import is that it will be part of the code
> base and should see fixes as the code changes over time.
>
> It should be possible to build a generator to take your client
> configuration and generate a set of CSV files.
> Once you have the CSV files you can then run them against the hammer
> interface and you have a fully configured system.
[…]
You could also use the Python CLI tool foreman-yml [1]. It allows you to
basically define your whole Foreman configuration in a YAML file and then
execute it to apply it to your Foreman instance. In addition it can also dump
an existing Foreman configuration into a YAML file.
The advantage to other CLI tools like hammer is that you don't need to resolve
all the template IDs etc. on your own. Instead you can define the canonical
name for it and foreman-yml will take care of resolving all IDs and linking
them accordingly. Here an example to add a new operating system:
os:
- name: Ubuntu
major: 14
minor: 4
description: Ubuntu 14.04 LTS
family: Debian
release-name: trusty
password-hash: SHA512
architecture:
- name: x86_64
provisioning-template:
- name: Ubuntu PXE
- name: Ubuntu Preseed
medium:
- name: Ubuntu Mirror
partition-table:
- name: Ubuntu Default
parameters:
version: "14.04"
codename: "trusty"
Maybe not all possible configuration options are currently implement. I think
the Location and Organization part is missing as we haven't had any use for it
so far but feel free to contribute or open pull requests and issues. 
Please note that the tool can currently on create or dump configs. Already
existing objects won't be updated but this shouldn't be too hard to implement.
[1] https://github.com/adfinis-sygroup/foreman-yml
Cheers
Michael
···
On Mon, 15 Aug 2016 09:01:15 -0400 Alvin Starr wrote:
Thank you for your response! I was moving to Sweden and it took my a while
to get completely setup here so thats why my reaction is a bit late. This
look like a viable way, although I am missing any information on how to
create/import a host. There is no explanation about in any of the examples.
Is this also possible or is this something that still needs to be
implemented?
···
Op maandag 15 augustus 2016 17:49:46 UTC+2 schreef Michael Hofer:
>
> Hi there
>
> On Mon, 15 Aug 2016 09:01:15 -0400 > Alvin Starr <al...@netvel.net > wrote:
> > I would +1 for the idea of using the CSV tools to upload a
> configuration.
> >
> > I have tried to use the CSV files to rebuild a configuration from
> > scratch and it kind of works but needs some work to fill out the corner
> > cases.
> >
> > The upside of using the CSV import is that it will be part of the code
> > base and should see fixes as the code changes over time.
> >
> > It should be possible to build a generator to take your client
> > configuration and generate a set of CSV files.
> > Once you have the CSV files you can then run them against the hammer
> > interface and you have a fully configured system.
> [...]
>
> You could also use the Python CLI tool foreman-yml [1]. It allows you to
> basically define your whole Foreman configuration in a YAML file and then
> execute it to apply it to your Foreman instance. In addition it can also
> dump
> an existing Foreman configuration into a YAML file.
>
> The advantage to other CLI tools like hammer is that you don't need to
> resolve
> all the template IDs etc. on your own. Instead you can define the
> canonical
> name for it and foreman-yml will take care of resolving all IDs and
> linking
> them accordingly. Here an example to add a new operating system:
>
> os:
> - name: Ubuntu
> major: 14
> minor: 4
> description: Ubuntu 14.04 LTS
> family: Debian
> release-name: trusty
> password-hash: SHA512
> architecture:
> - name: x86_64
> provisioning-template:
> - name: Ubuntu PXE
> - name: Ubuntu Preseed
> medium:
> - name: Ubuntu Mirror
> partition-table:
> - name: Ubuntu Default
> parameters:
> version: "14.04"
> codename: "trusty"
>
> Maybe not all possible configuration options are currently implement. I
> think
> the Location and Organization part is missing as we haven't had any use
> for it
> so far but feel free to contribute or open pull requests and issues. :)
>
> Please note that the tool can currently on create or dump configs. Already
> existing objects won't be updated but this shouldn't be too hard to
> implement.
>
> [1] https://github.com/adfinis-sygroup/foreman-yml
>
>
> Cheers
>
> Michael
>
Hey Maurice
> Thank you for your response! I was moving to Sweden and it took my a while
> to get completely setup here so thats why my reaction is a bit late. This
> look like a viable way, although I am missing any information on how to
> create/import a host. There is no explanation about in any of the examples.
> Is this also possible or is this something that still needs to be
> implemented?
[…]
You're right the host related config was missing in the documentation and has
been added. Please note that so far we've only used it to add new hosts without
configuring the IP address or subnet. Meaning maybe some fields that you need
are missing. If possible open a GitHub issue with the fields you require or you
can of course fit it on your own. 
Cheers
Michael
···
On Mon, 19 Sep 2016 03:38:27 -0700 (PDT) Maurice Mouw wrote: