SSH Provisioning

Hello all,

I am attempting to use Foreman to provision a Linux VM on VMware, and to
use a finishing script over SSH. The VM deploys fine, but instead of being
run on the VM, the finishing script is run on the Foreman box itself.

Here's the template:
#!/bin/bash

wall "Test"

cat /etc/puppet/puppet.conf << EOF

[main]
vardir = /var/lib/puppet
logdir = /var/log/puppet
rundir = /var/run/puppet
ssldir = $vardir/ssl

[agent]
pluginsync=true
report = true
ignoreschedules = true
ca_server = <My CA server>
certname = <%= @host.name %>
environment = production
server = <My puppet master>

EOF

puppet_unit=puppet
/usr/bin/systemctl list-unit-files | grep -q puppetagent && puppet_unit=
puppetagent
/usr/bin/systemctl enable ${puppet_unit}
/sbin/chkconfig --level 345 puppet on

export FACTER_is_installer=true

/usr/bin/puppet agent --config /etc/puppet/puppet.conf --onetime --tags
no_such_tag --server <My puppet master> --no-daemonize

if [ -f /usr.bin/dnf]; then
dnf -y update
else
yum -t -y update
fi

sync

exit 0

I realize there are some errors with the template, and the wall was only
placed there as a troubleshooting measure, but I have no idea what could be
causing Foreman to execute this template on itself instead of on the VM.
Any help is appreciated.

Thanks,

Tyler

Foreman connects to the IP address that is defined for your
provisioning NIC, check the IP and routing from Foreman server.

LZ

··· On Mon, Mar 27, 2017 at 10:37 PM, Tyler Gregory wrote: > Hello all, > > I am attempting to use Foreman to provision a Linux VM on VMware, and to use > a finishing script over SSH. The VM deploys fine, but instead of being run > on the VM, the finishing script is run on the Foreman box itself. > > Here's the template: > #!/bin/bash > > wall "Test" > > cat /etc/puppet/puppet.conf < > [main] > vardir = /var/lib/puppet > logdir = /var/log/puppet > rundir = /var/run/puppet > ssldir = \$vardir/ssl > > [agent] > pluginsync=true > report = true > ignoreschedules = true > ca_server = > certname = <%= @host.name %> > environment = production > server = > > > EOF > > > puppet_unit=puppet > /usr/bin/systemctl list-unit-files | grep -q puppetagent && > puppet_unit=puppetagent > /usr/bin/systemctl enable ${puppet_unit} > /sbin/chkconfig --level 345 puppet on > > > export FACTER_is_installer=true > > > /usr/bin/puppet agent --config /etc/puppet/puppet.conf --onetime --tags > no_such_tag --server --no-daemonize > > > if [ -f /usr.bin/dnf]; then > dnf -y update > else > yum -t -y update > fi > > > sync > > > exit 0 > > > I realize there are some errors with the template, and the wall was only > placed there as a troubleshooting measure, but I have no idea what could be > causing Foreman to execute this template on itself instead of on the VM. Any > help is appreciated. > > Thanks, > > Tyler > > -- > 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.


Later,
Lukas @lzap Zapletal

That's definitely what I'm doing wrong, but isn't it odd that Foreman runs
the templates on itself in the absence of a provisioning IP address?

··· On Tuesday, March 28, 2017 at 4:40:15 AM UTC-5, Lukas Zapletal wrote: > > Foreman connects to the IP address that is defined for your > provisioning NIC, check the IP and routing from Foreman server. > > LZ > > On Mon, Mar 27, 2017 at 10:37 PM, Tyler Gregory > wrote: > > Hello all, > > > > I am attempting to use Foreman to provision a Linux VM on VMware, and to > use > > a finishing script over SSH. The VM deploys fine, but instead of being > run > > on the VM, the finishing script is run on the Foreman box itself. > > > > Here's the template: > > #!/bin/bash > > > > wall "Test" > > > > cat /etc/puppet/puppet.conf < > > > [main] > > vardir = /var/lib/puppet > > logdir = /var/log/puppet > > rundir = /var/run/puppet > > ssldir = \$vardir/ssl > > > > [agent] > > pluginsync=true > > report = true > > ignoreschedules = true > > ca_server = > > certname = <%= @host.name %> > > environment = production > > server = > > > > > > EOF > > > > > > puppet_unit=puppet > > /usr/bin/systemctl list-unit-files | grep -q puppetagent && > > puppet_unit=puppetagent > > /usr/bin/systemctl enable ${puppet_unit} > > /sbin/chkconfig --level 345 puppet on > > > > > > export FACTER_is_installer=true > > > > > > /usr/bin/puppet agent --config /etc/puppet/puppet.conf --onetime --tags > > no_such_tag --server --no-daemonize > > > > > > if [ -f /usr.bin/dnf]; then > > dnf -y update > > else > > yum -t -y update > > fi > > > > > > sync > > > > > > exit 0 > > > > > > I realize there are some errors with the template, and the wall was only > > placed there as a troubleshooting measure, but I have no idea what could > be > > causing Foreman to execute this template on itself instead of on the VM. > Any > > help is appreciated. > > > > Thanks, > > > > Tyler > > > > -- > > 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-user...@googlegroups.com . > > To post to this group, send email to forema...@googlegroups.com > . > > Visit this group at https://groups.google.com/group/foreman-users. > > For more options, visit https://groups.google.com/d/optout. > > > > -- > Later, > Lukas @lzap Zapletal >

Foreman really does this: ssh user@IP_OF_HOST "run script"

So make sure the IP is correctly routed, I have no idea why it would
connect to itself.

LZ

··· On Tue, Mar 28, 2017 at 3:09 PM, Tyler Gregory wrote: > That's definitely what I'm doing wrong, but isn't it odd that Foreman runs > the templates on itself in the absence of a provisioning IP address? > > On Tuesday, March 28, 2017 at 4:40:15 AM UTC-5, Lukas Zapletal wrote: >> >> Foreman connects to the IP address that is defined for your >> provisioning NIC, check the IP and routing from Foreman server. >> >> LZ >> >> On Mon, Mar 27, 2017 at 10:37 PM, Tyler Gregory wrote: >> > Hello all, >> > >> > I am attempting to use Foreman to provision a Linux VM on VMware, and to >> > use >> > a finishing script over SSH. The VM deploys fine, but instead of being >> > run >> > on the VM, the finishing script is run on the Foreman box itself. >> > >> > Here's the template: >> > #!/bin/bash >> > >> > wall "Test" >> > >> > cat /etc/puppet/puppet.conf <> > >> > [main] >> > vardir = /var/lib/puppet >> > logdir = /var/log/puppet >> > rundir = /var/run/puppet >> > ssldir = \$vardir/ssl >> > >> > [agent] >> > pluginsync=true >> > report = true >> > ignoreschedules = true >> > ca_server = >> > certname = <%= @host.name %> >> > environment = production >> > server = >> > >> > >> > EOF >> > >> > >> > puppet_unit=puppet >> > /usr/bin/systemctl list-unit-files | grep -q puppetagent && >> > puppet_unit=puppetagent >> > /usr/bin/systemctl enable ${puppet_unit} >> > /sbin/chkconfig --level 345 puppet on >> > >> > >> > export FACTER_is_installer=true >> > >> > >> > /usr/bin/puppet agent --config /etc/puppet/puppet.conf --onetime --tags >> > no_such_tag --server --no-daemonize >> > >> > >> > if [ -f /usr.bin/dnf]; then >> > dnf -y update >> > else >> > yum -t -y update >> > fi >> > >> > >> > sync >> > >> > >> > exit 0 >> > >> > >> > I realize there are some errors with the template, and the wall was only >> > placed there as a troubleshooting measure, but I have no idea what could >> > be >> > causing Foreman to execute this template on itself instead of on the VM. >> > Any >> > help is appreciated. >> > >> > Thanks, >> > >> > Tyler >> > >> > -- >> > 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-user...@googlegroups.com. >> > To post to this group, send email to forema...@googlegroups.com. >> > Visit this group at https://groups.google.com/group/foreman-users. >> > For more options, visit https://groups.google.com/d/optout. >> >> >> >> -- >> Later, >> Lukas @lzap Zapletal > > -- > 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.


Later,
Lukas @lzap Zapletal

Well, the field was blank because I'd overlooked that, so it looks like the
template was rendered, then copied to /root on the Foreman box, and then
executed there. I could understand why this would happen if I'd put
127.0.0.1 or ::1 as the provisioning IP, but it was simply blank.

Either way, thanks for making me realize that I need to supply an IP to get
SSH provisioning up and running. I clearly need more coffee.

··· On Tuesday, March 28, 2017 at 8:23:37 AM UTC-5, Lukas Zapletal wrote: > > Foreman really does this: ssh user@IP_OF_HOST "run script" > > So make sure the IP is correctly routed, I have no idea why it would > connect to itself. > > LZ > > On Tue, Mar 28, 2017 at 3:09 PM, Tyler Gregory > wrote: > > That's definitely what I'm doing wrong, but isn't it odd that Foreman > runs > > the templates on itself in the absence of a provisioning IP address? > > > > On Tuesday, March 28, 2017 at 4:40:15 AM UTC-5, Lukas Zapletal wrote: > >> > >> Foreman connects to the IP address that is defined for your > >> provisioning NIC, check the IP and routing from Foreman server. > >> > >> LZ > >> > >> On Mon, Mar 27, 2017 at 10:37 PM, Tyler Gregory > wrote: > >> > Hello all, > >> > > >> > I am attempting to use Foreman to provision a Linux VM on VMware, and > to > >> > use > >> > a finishing script over SSH. The VM deploys fine, but instead of > being > >> > run > >> > on the VM, the finishing script is run on the Foreman box itself. > >> > > >> > Here's the template: > >> > #!/bin/bash > >> > > >> > wall "Test" > >> > > >> > cat /etc/puppet/puppet.conf < >> > > >> > [main] > >> > vardir = /var/lib/puppet > >> > logdir = /var/log/puppet > >> > rundir = /var/run/puppet > >> > ssldir = \$vardir/ssl > >> > > >> > [agent] > >> > pluginsync=true > >> > report = true > >> > ignoreschedules = true > >> > ca_server = > >> > certname = <%= @host.name %> > >> > environment = production > >> > server = > >> > > >> > > >> > EOF > >> > > >> > > >> > puppet_unit=puppet > >> > /usr/bin/systemctl list-unit-files | grep -q puppetagent && > >> > puppet_unit=puppetagent > >> > /usr/bin/systemctl enable ${puppet_unit} > >> > /sbin/chkconfig --level 345 puppet on > >> > > >> > > >> > export FACTER_is_installer=true > >> > > >> > > >> > /usr/bin/puppet agent --config /etc/puppet/puppet.conf --onetime > --tags > >> > no_such_tag --server --no-daemonize > >> > > >> > > >> > if [ -f /usr.bin/dnf]; then > >> > dnf -y update > >> > else > >> > yum -t -y update > >> > fi > >> > > >> > > >> > sync > >> > > >> > > >> > exit 0 > >> > > >> > > >> > I realize there are some errors with the template, and the wall was > only > >> > placed there as a troubleshooting measure, but I have no idea what > could > >> > be > >> > causing Foreman to execute this template on itself instead of on the > VM. > >> > Any > >> > help is appreciated. > >> > > >> > Thanks, > >> > > >> > Tyler > >> > > >> > -- > >> > 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-user...@googlegroups.com. > >> > To post to this group, send email to forema...@googlegroups.com. > >> > Visit this group at https://groups.google.com/group/foreman-users. > >> > For more options, visit https://groups.google.com/d/optout. > >> > >> > >> > >> -- > >> Later, > >> Lukas @lzap Zapletal > > > > -- > > 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-user...@googlegroups.com . > > To post to this group, send email to forema...@googlegroups.com > . > > Visit this group at https://groups.google.com/group/foreman-users. > > For more options, visit https://groups.google.com/d/optout. > > > > -- > Later, > Lukas @lzap Zapletal >

Oh I overlook youre on VMWare, normally compute resource does return
IP address so you don't need to provide it manually, but VMWare
integration does not work (although VMWare is capable of doing that we
don't read that).

But why it was connecting to localhost is a bit mystery still.

··· On Tue, Mar 28, 2017 at 3:39 PM, Tyler Gregory wrote: > Well, the field was blank because I'd overlooked that, so it looks like the > template was rendered, then copied to /root on the Foreman box, and then > executed there. I could understand why this would happen if I'd put > 127.0.0.1 or ::1 as the provisioning IP, but it was simply blank. > > Either way, thanks for making me realize that I need to supply an IP to get > SSH provisioning up and running. I clearly need more coffee. > > On Tuesday, March 28, 2017 at 8:23:37 AM UTC-5, Lukas Zapletal wrote: >> >> Foreman really does this: ssh user@IP_OF_HOST "run script" >> >> So make sure the IP is correctly routed, I have no idea why it would >> connect to itself. >> >> LZ >> >> On Tue, Mar 28, 2017 at 3:09 PM, Tyler Gregory wrote: >> > That's definitely what I'm doing wrong, but isn't it odd that Foreman >> > runs >> > the templates on itself in the absence of a provisioning IP address? >> > >> > On Tuesday, March 28, 2017 at 4:40:15 AM UTC-5, Lukas Zapletal wrote: >> >> >> >> Foreman connects to the IP address that is defined for your >> >> provisioning NIC, check the IP and routing from Foreman server. >> >> >> >> LZ >> >> >> >> On Mon, Mar 27, 2017 at 10:37 PM, Tyler Gregory >> >> wrote: >> >> > Hello all, >> >> > >> >> > I am attempting to use Foreman to provision a Linux VM on VMware, and >> >> > to >> >> > use >> >> > a finishing script over SSH. The VM deploys fine, but instead of >> >> > being >> >> > run >> >> > on the VM, the finishing script is run on the Foreman box itself. >> >> > >> >> > Here's the template: >> >> > #!/bin/bash >> >> > >> >> > wall "Test" >> >> > >> >> > cat /etc/puppet/puppet.conf <> >> > >> >> > [main] >> >> > vardir = /var/lib/puppet >> >> > logdir = /var/log/puppet >> >> > rundir = /var/run/puppet >> >> > ssldir = \$vardir/ssl >> >> > >> >> > [agent] >> >> > pluginsync=true >> >> > report = true >> >> > ignoreschedules = true >> >> > ca_server = >> >> > certname = <%= @host.name %> >> >> > environment = production >> >> > server = >> >> > >> >> > >> >> > EOF >> >> > >> >> > >> >> > puppet_unit=puppet >> >> > /usr/bin/systemctl list-unit-files | grep -q puppetagent && >> >> > puppet_unit=puppetagent >> >> > /usr/bin/systemctl enable ${puppet_unit} >> >> > /sbin/chkconfig --level 345 puppet on >> >> > >> >> > >> >> > export FACTER_is_installer=true >> >> > >> >> > >> >> > /usr/bin/puppet agent --config /etc/puppet/puppet.conf --onetime >> >> > --tags >> >> > no_such_tag --server --no-daemonize >> >> > >> >> > >> >> > if [ -f /usr.bin/dnf]; then >> >> > dnf -y update >> >> > else >> >> > yum -t -y update >> >> > fi >> >> > >> >> > >> >> > sync >> >> > >> >> > >> >> > exit 0 >> >> > >> >> > >> >> > I realize there are some errors with the template, and the wall was >> >> > only >> >> > placed there as a troubleshooting measure, but I have no idea what >> >> > could >> >> > be >> >> > causing Foreman to execute this template on itself instead of on the >> >> > VM. >> >> > Any >> >> > help is appreciated. >> >> > >> >> > Thanks, >> >> > >> >> > Tyler >> >> > >> >> > -- >> >> > 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-user...@googlegroups.com. >> >> > To post to this group, send email to forema...@googlegroups.com. >> >> > Visit this group at https://groups.google.com/group/foreman-users. >> >> > For more options, visit https://groups.google.com/d/optout. >> >> >> >> >> >> >> >> -- >> >> Later, >> >> Lukas @lzap Zapletal >> > >> > -- >> > 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-user...@googlegroups.com. >> > To post to this group, send email to forema...@googlegroups.com. >> > Visit this group at https://groups.google.com/group/foreman-users. >> > For more options, visit https://groups.google.com/d/optout. >> >> >> >> -- >> Later, >> Lukas @lzap Zapletal > > -- > 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.


Later,
Lukas @lzap Zapletal