Best way to update proxy and CA server for all hosts

Hi,

I have a few hundred hosts that I need to change the proxy and CA server
for. It seems I have to Edit each host and change them manually. Any quick
way to change them from the GUI, hammer cli, or raw DB query? I'm running
Foreman 1.9.2. I know it can be set to "inherit from Parent" , but I don't
think that option was there when I started using Foreman a few years ago,
so they are all explicitly set to an old proxy server.

Thanks for any ideas,
Jason

Pretty sure you can do this with hammer:

$ hammer host update --help

–puppet-ca-proxy PUPPET_CA_PROXY_NAME
–puppet-ca-proxy-id PUPPET_CA_PROXY_ID
–puppet-proxy PUPPET_PROXY_NAME
–puppet-proxy-id PUPPET_PROXY_ID

I guess you'd have to loop over all the hosts one at a time, but at
least it's not manual.

Greg

··· On 20 November 2015 at 14:12, Jason Ashby wrote: > Hi, > > I have a few hundred hosts that I need to change the proxy and CA server > for. It seems I have to Edit each host and change them manually. Any quick > way to change them from the GUI, hammer cli, or raw DB query? I'm running > Foreman 1.9.2. I know it can be set to "inherit from Parent" , but I don't > think that option was there when I started using Foreman a few years ago, so > they are all explicitly set to an old proxy server.

I pretty much did the same thing last week. You just get a list of hosts
either from the DB or hammer and put it in a file, then run it through a
loop of your choice to invoke hammer.

Test and change as needed, as this is off the top of my head

for i incat host-list ; do hammer host update --name $i --puppet-ca-proxy
foo-proxy ; done

It helps to, at least temporarily, put your credentials in a .hammer config
so you don't have to enter your username/password hundreds of times. Make
sure you have an updated version of hammer, though, as I tried this with a
fairly old version and it cleared my puppet proxy when I updated my puppet
ca proxy! 0.3 seemed fine, though.

··· On Friday, November 20, 2015 at 9:42:06 AM UTC-8, Greg Sutcliffe wrote: > > On 20 November 2015 at 14:12, Jason Ashby <jas...@gmail.com > > wrote: > > Hi, > > > > I have a few hundred hosts that I need to change the proxy and CA server > > for. It seems I have to Edit each host and change them manually. Any > quick > > way to change them from the GUI, hammer cli, or raw DB query? I'm > running > > Foreman 1.9.2. I know it can be set to "inherit from Parent" , but I > don't > > think that option was there when I started using Foreman a few years > ago, so > > they are all explicitly set to an old proxy server. > > Pretty sure you can do this with hammer: > > $ hammer host update --help > ... > --puppet-ca-proxy PUPPET_CA_PROXY_NAME > --puppet-ca-proxy-id PUPPET_CA_PROXY_ID > --puppet-proxy PUPPET_PROXY_NAME > --puppet-proxy-id PUPPET_PROXY_ID > > I guess you'd have to loop over all the hosts one at a time, but at > least it's not manual. > > Greg >

Perfect, thanks all. I dumped a list of IDs and looped over them with:

sudo hammer -c myconfig.yml --output csv host list | cut -d',' -f1 >
hostlist
for i in cat hostlist ; do sudo hammer -d -c myconfig.yml host update --id
$i --puppet-ca-proxy-id 2 --puppet-proxy-id 2 ; done

where 2 is my proxy's ID per sudo hammer proxy list.

··· On Saturday, November 21, 2015 at 3:19:46 PM UTC-5, Alyssa wrote: > > I pretty much did the same thing last week. You just get a list of hosts > either from the DB or hammer and put it in a file, then run it through a > loop of your choice to invoke hammer. > # Test and change as needed, as this is off the top of my head > for i in`cat host-list` ; do hammer host update --name $i --puppet-ca-proxy > foo-proxy ; done > > > It helps to, at least temporarily, put your credentials in a .hammer > config so you don't have to enter your username/password hundreds of times. > Make sure you have an updated version of hammer, though, as I tried this > with a fairly old version and it cleared my puppet proxy when I updated my > puppet ca proxy! 0.3 seemed fine, though. > > On Friday, November 20, 2015 at 9:42:06 AM UTC-8, Greg Sutcliffe wrote: >> >> On 20 November 2015 at 14:12, Jason Ashby wrote: >> > Hi, >> > >> > I have a few hundred hosts that I need to change the proxy and CA >> server >> > for. It seems I have to Edit each host and change them manually. Any >> quick >> > way to change them from the GUI, hammer cli, or raw DB query? I'm >> running >> > Foreman 1.9.2. I know it can be set to "inherit from Parent" , but I >> don't >> > think that option was there when I started using Foreman a few years >> ago, so >> > they are all explicitly set to an old proxy server. >> >> Pretty sure you can do this with hammer: >> >> $ hammer host update --help >> ... >> --puppet-ca-proxy PUPPET_CA_PROXY_NAME >> --puppet-ca-proxy-id PUPPET_CA_PROXY_ID >> --puppet-proxy PUPPET_PROXY_NAME >> --puppet-proxy-id PUPPET_PROXY_ID >> >> I guess you'd have to loop over all the hosts one at a time, but at >> least it's not manual. >> >> Greg >> >

I also needed to update the proxy for all hostgroups. Just run the same
commands but use hostgroup instead of host.

··· On Wednesday, November 25, 2015 at 9:33:50 AM UTC-5, Jason Ashby wrote: > > Perfect, thanks all. I dumped a list of IDs and looped over them with: > > > sudo hammer -c myconfig.yml --output csv host list | cut -d',' -f1 > > hostlist > for i in `cat hostlist` ; do sudo hammer -d -c myconfig.yml host update --id > $i --puppet-ca-proxy-id 2 --puppet-proxy-id 2 ; done > > > where 2 is my proxy's ID per `sudo hammer proxy list`. > > > On Saturday, November 21, 2015 at 3:19:46 PM UTC-5, Alyssa wrote: >> >> I pretty much did the same thing last week. You just get a list of hosts >> either from the DB or hammer and put it in a file, then run it through a >> loop of your choice to invoke hammer. >> # Test and change as needed, as this is off the top of my head >> for i in`cat host-list` ; do hammer host update --name $i --puppet-ca-proxy >> foo-proxy ; done >> >> >> It helps to, at least temporarily, put your credentials in a .hammer >> config so you don't have to enter your username/password hundreds of times. >> Make sure you have an updated version of hammer, though, as I tried this >> with a fairly old version and it cleared my puppet proxy when I updated my >> puppet ca proxy! 0.3 seemed fine, though. >> >> On Friday, November 20, 2015 at 9:42:06 AM UTC-8, Greg Sutcliffe wrote: >>> >>> On 20 November 2015 at 14:12, Jason Ashby wrote: >>> > Hi, >>> > >>> > I have a few hundred hosts that I need to change the proxy and CA >>> server >>> > for. It seems I have to Edit each host and change them manually. Any >>> quick >>> > way to change them from the GUI, hammer cli, or raw DB query? I'm >>> running >>> > Foreman 1.9.2. I know it can be set to "inherit from Parent" , but I >>> don't >>> > think that option was there when I started using Foreman a few years >>> ago, so >>> > they are all explicitly set to an old proxy server. >>> >>> Pretty sure you can do this with hammer: >>> >>> $ hammer host update --help >>> ... >>> --puppet-ca-proxy PUPPET_CA_PROXY_NAME >>> --puppet-ca-proxy-id PUPPET_CA_PROXY_ID >>> --puppet-proxy PUPPET_PROXY_NAME >>> --puppet-proxy-id PUPPET_PROXY_ID >>> >>> I guess you'd have to loop over all the hosts one at a time, but at >>> least it's not manual. >>> >>> Greg >>> >>