Hi Erez,

Thats what i suspected,
I want to use foremans ENC to set the hostname,
foreman stores a hostname against each interface/mac address,
as Marek mentioned Hostname is always synced to the primary interface name 
in foreman,
the primary interface value is not a node side fact and is only in the ENC

what i'm stuck on is how to consume that information in puppet,
how can i retrieve the information,
if i could iterate i would iterate through each item (mac address) in 
foreman_interfaces: and return the hostname value for the item(mac address) 
that has primary = true

here is a cleaned output of a hosts YAML output provided by the ENC for 
foreman as an example of what i am looking at.

parameters:
  puppetmaster: puppet
  hostgroup: HostGroup1/Example2
  root_pw: 
  foreman_env: development
  owner_name:
  owner_email:
  foreman_subnets: []
  foreman_interfaces:
  - mac: 6a:ab:a5:a4:1a:99
    ip: 10.1.1.1
    type: Interface
    name: myhost.mydomain.tld
    attrs:
      netmask: 255.255.255.0
      mtu: '1500'
      network: 10.1.1.0
    virtual: false
    link: true
    identifier: en0
    managed: true
    primary: true
    provision: true
    subnet: 
  - mac: a8:a0:ab:5a:ea:1f
    ip: 
    type: Interface
    name: ''
    attrs:
      mtu: '1500'
    virtual: false
    link: true
    identifier: en1
    managed: false
    primary: false
    provision: false
    subnet: 


Cheers,
Luke


On Friday, 9 September 2016 22:19:17 UTC+10, Erez Zarum wrote:
>
> What do you mean?
> This was running on a host/puppet agent (not the puppet master server), 
> it's the host's facts
>
> On Friday, September 9, 2016 at 3:17:55 AM UTC+3, Luke Tinker wrote:
>>
>> I thought you could not access server facts from a host?
>> which is part of what has made trying to get my head around consuming 
>> some of the outputs from the ENC.
>>
>> Cheers,
>> Luke
>>
>> On Thursday, 8 September 2016 20:55:27 UTC+10, Erez Zarum wrote:
>>>
>>> You can always debug with facter
>>> $ facter networking.hostname networking.fqdn networking.primary 
>>> networking.mac networking.interfaces.eth0.mac
>>> networking.fqdn => server01.example.com
>>> networking.hostname => server01
>>> networking.interfaces.eth0.mac => 00:50:51:8f:dg:a3
>>> networking.mac => 00:50:51:8f:dg:a3
>>> networking.primary => eth0
>>>
>>>
>>>
>>> On Thursday, September 8, 2016 at 10:56:43 AM UTC+3, Luke Tinker wrote:
>>>>
>>>> Thanks for the help Marek,
>>>>
>>>> How do i access consume the primary interface details in puppet?
>>>> forman_interface: provides the array of mac addresses,
>>>> however because i don't know the mac address that is primary i am not 
>>>> sure how to check the attributes associated with it,
>>>> i cant find any examples of how to go about this.
>>>>
>>>> what i want to do is go,
>>>>
>>>> $hostname = foreman_interface:mac:00:00:00:00:name if 
>>>> foreman_interface:mac:00:00:00:00:primary
>>>>
>>>> On Wednesday, 7 September 2016 17:38:42 UTC+10, Marek Hulán wrote:
>>>>>
>>>>> On Tuesday 06 of September 2016 20:41:13 Luke Tinker wrote: 
>>>>> > Hi everyone, 
>>>>> > 
>>>>> > hopefully someone can point me in the right direction here 
>>>>> > I started using foreman earlier this year, 
>>>>> > 
>>>>> > The short of what i want to achieve is have Foreman Host Name field 
>>>>> > provided as a fact so puppet can use it to ensure the hostname is 
>>>>> enforced, 
>>>>> > this is so when a machine is pre-created in foreman, puppet can 
>>>>> ensure its 
>>>>> > hostname is always correct, 
>>>>> > also making renaming the machine possible via foreman. 
>>>>> > 
>>>>> > The most obvious place to find this information is via the YAML 
>>>>> output 
>>>>> > values provided per host, specifically the primary interface's name 
>>>>> value. 
>>>>> > however is this the best source, is it possible to get the host name 
>>>>> from 
>>>>> > the Name* field when you go to edit a host, thus allowing for the 
>>>>> direct 
>>>>> > change if its name is changed? 
>>>>> > 
>>>>> > any assistance would be greatly appreciated, even if its a simple 
>>>>> push in a 
>>>>> > certain direction. 
>>>>> > 
>>>>> > Cheers, 
>>>>> > Luke 
>>>>>
>>>>> Hello 
>>>>>
>>>>> I'd say it's a good source. A host name + primary interface domain 
>>>>> name is 
>>>>> what give us host FQDN. Host name is always synced to primary 
>>>>> interface name. 
>>>>>
>>>>> Hope this helps 
>>>>>
>>>>> -- 
>>>>> Marek 
>>>>>
>>>>

-- 
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