Установка foreman в существующей puppet инфраструктуре
03 Jun 2017Установка foreman-installer на Ubuntu 14.04
apt-get -y install ca-certificates
wget https://apt.puppetlabs.com/puppetlabs-release-trusty.deb
dpkg -i puppetlabs-release-trusty.deb
Enable the Foreman repo:
echo "deb http://deb.theforeman.org/ trusty 1.15" > /etc/apt/sources.list.d/foreman.list
echo "deb http://deb.theforeman.org/ plugins 1.15" >> /etc/apt/sources.list.d/foreman.list
apt-get -y install ca-certificates
wget -q https://deb.theforeman.org/pubkey.gpg -O- | apt-key add -
Downloading the installer
apt-get update && apt-get -y install foreman-installer
Установка на сервере foreman.example.com
foreman-installer \
--puppet-server=false \
--no-enable-puppet \
--foreman-proxy-puppet=false \
--foreman-proxy-puppetca=false
Installing Done [100%]
Something went wrong! Check the log for ERROR-level output
* Foreman is running at https://logstash.satin-pl.com
Initial credentials are admin / NtKpRHdAn8HdSSFr
* Foreman Proxy is running at https://logstash.satin-pl.com:8443
The full log is at /var/log/foreman-installer/foreman.log
При установки возникли ошибки, так как мы отказались установки puppet, не было сертификата. Из-за этого не запускался apache2. Решение: Зарегистрировать puppet агента на сервере (соответственно будет сгенерирован новый сертификат) и перезапуск apache2.
Установка на сервере puppet.example.com
foreman-installer \
--no-enable-foreman \
--no-enable-foreman-cli \
--no-enable-foreman-plugin-bootdisk \
--no-enable-foreman-plugin-setup \
--puppet-server=false \
--no-enable-puppet \
--enable-foreman-proxy \
--enable-foreman-proxy-plugin-monitoring \
--foreman-proxy-tftp=false \
--foreman-proxy-puppet=true \
--foreman-proxy-puppetca=true \
--foreman-proxy-dns=false \
--foreman-proxy-dhcp=false \
--foreman-proxy-foreman-base-url=https://logstash.satin-pl.com \
--foreman-proxy-trusted-hosts=logstash.satin-pl.com \
--foreman-proxy-oauth-consumer-key=qd32iP8aBfLw6wtSzjtEFzLfU7BJtBhN \
--foreman-proxy-oauth-consumer-secret=B798VPjS7diKb4MGtGEB7X2Y9pranD6R
Installing Done [100%] [..........................................]
Something went wrong! Check the log for ERROR-level output
* Foreman Proxy is running at https://icinga2.satin-pl.com:8443
The full log is at /var/log/foreman-installer/foreman.log
В этом случае тоже были ошибки, так как fqdn сервера определялся как внешний IP-адрес. Пришлось на обоих серверах в файле /etc/hosts
прописывать внутрение IP-адреса:
192.168.0.208 logstash.satin-pl.com
192.168.0.208 foreman.satin-pl.com
192.168.0.209 icinga2.satin-pl.com
Facts и ENC в Foreman
Foreman может выступать в качестве классификатора для Puppet через интерфейс внешних узлов. Это механизм, предоставляемый Puppet для запроса данных конфигурации из внешней службы через скрипт puppetmaster.
Puppetmaster
Copy node.rb to the Puppet configuration directory, e.g. /etc/puppet
The name you choose for the file is arbitrary, but we will assume node.rb
, e.g. /etc/puppet/node.rb
. Ensure it is executable by the puppet user.
Edit the new file, and configure the settings:
url - The address of the Foreman server (e.g. http://foreman )
puppetdir - The location of Puppet’s cache dir (e.g. /var/lib/puppet )
ssl_* - SSL certs as per Securing Communications With SSL
Add the following lines to the [master] section of puppet.conf:
external_nodes = /etc/puppet/node.rb
node_terminus = exec
Перезапустите puppetmaster. Когда следующий агент подключиться, puppetmaster загрузит данные об этом для этого хоста Foreman и загрузит данные ENC.
The --no-environment
option can be optionally specified to stop the ENC from being authoritative about the agent’s Puppet environment. This can be useful in development setups where the agent may be run against different environments.
Client
Для использования этой функции не требуется конфигурация агента.
Тестирование конфигурации
Make sure that the puppet user can execute the ENC script and it works:
sudo -u puppet /etc/puppet/node.rb [the name of a node, eg agent.local]
Вылезла проблема с кодировкой на Windows агентах! Решение: Попробуйте сделать эти изменения в /etc/puppet/node.rb: https://github.com/theforeman/puppet-foreman/commit/d21eef907535b88fd9271f7a5761bde31e72b231 Это исправление должно быть в новых установках Foreman 1.8. Проблема заключается в том, что когда node.rb запускается из puppetmaster, он запускается в локали 'C', поэтому не может анализировать данные часовых поясов в UTF-8 от клиентов Windows.
Отправка facts в Foreman, когда не используется функциональность ENC
Существует несколько вариантов форматирования данных фактов для Foreman, если вы используете Foreman только для отчетности/инвентаризации.
Скрипт ENC (node.rb) принимает возможность запускать в «пакетном режиме». В этом режиме скрипт перебирает данные кэшированного факта, хранящиеся на puppetmaster, и загружает все это в Foreman.
Загрузите и настройте сценарий node.rb, а затем вызовите его следующим образом:
sudo -u puppet /etc/puppet/node.rb --push-facts
Для пакетного режима node.rb
доступны следующие параметры:
--push-facts
uploads all facts sequentially which have changed since the last run.
--push-facts-parallel
uploads all facts in parallel which have changed since the last run. The number of threads is specified by the :threads setting or the number of processors.
--watch-facts
runs in the foreground and upload facts based on inotify events, used in conjunction with either –push-facts option.