Smart Proxy: различия между версиями

Материал из ALT Linux Wiki
(Добавление настройки плагина remote-execution)
Строка 114: Строка 114:


=== Добавление плагина ===
=== Добавление плагина ===


В зависимости от установленной версии smart-proxy выбираем каталог с примерами конфигурационных файлов.
В зависимости от установленной версии smart-proxy выбираем каталог с примерами конфигурационных файлов.
Строка 141: Строка 140:
  # systemctl restart smart-proxy
  # systemctl restart smart-proxy


==== Настройка плагина remote-execution ====
Для запуска функционала '''remote-execution''' проверяем наличие и содержимое файлов ниже
''/etc/smart-proxy/config/settings.d/dynflow.yml''
<source lang="bash">
---
:enabled: http
:use_http: true
:database:
:core_url: http://sample.server.name:8008
# If true, external core will be used even if the core gem is available
# If false, the feature will be disabled if the core gem is unavailable
# If unset, the process will fallback to autodetection, using external core if the core gem is unavailable
:external_core: true
</source>
''/etc/smart-proxy/config/settings.d/remote_execution_ssh.yml''
<source lang="bash">
---
:enabled: true
:ssh_identity_key_file: /var/lib/smart-proxy/.ssh/id_rsa_foreman_proxy
:local_working_dir: /var/tmp
:remote_working_dir: /var/tmp
:kerberos_auth: false
# Whether to run remote execution jobs asynchronously
:async_ssh: false
</source>
Редактируем файл ''/etc/smart_proxy_dynflow_core/settings.yml''
<source lang="bash">
---
# Path to dynflow database, leave blank for in-memory non-persistent database
:database:
# URL of the foreman, used for reporting back
:foreman_url: 'http://sample.server.name:2345'
# SSL settings for client authentication against Foreman
:foreman_ssl_ca: /etc/smart-proxy/ssl/certs/ca.pem
:foreman_ssl_key: /etc/smart-proxy/ssl/private_keys/sample.server.name.pem
:foreman_ssl_cert: /etc/smart-proxy/ssl/certs/sample.server.name.pem
:console_auth: true
# Listen on address
:listen: 0.0.0.0
# Listen on port
:port: 8008
# SSL settings for running core as https service
:use_https: false
:ssl_ca_file: /etc/smart-proxy/ssl/certs/ca.pem
:ssl_private_key: /etc/smart-proxy/ssl/private_keys/sample.server.name.pem
:ssl_certificate: /etc/smart-proxy/ssl/certs/sample.server.name.pem
# File to log to, leave empty for logging to STDOUT
:log_file: /var/log/smart-proxy/smart_proxy_dynflow_core.log
</source>
Создаем пару RSA ключей для пользователя '''_smartforeman'''
От имени пользователя '''root''' запускаем:
<source lang="bash">
# su - _smartforeman
$ mkdir /var/lib/smart-proxy/.ssh
$ ssh-keygen -t rsa -f .ssh/id_rsa_foreman_proxy
</source>
Для удаленного запуска команд потребуется зарегистрировать созданный ключ в ''/root/.ssh/authorized_keys''
<pre>
# cat /var/lib/smart-proxy/.ssh/id_rsa_foreman_proxy.pub >> /root/.ssh/authorized_keys
</pre>
Разрешаем необходимые сервисы и запускаем их
<pre>
# systemctl enable foreman-jobs
# systemctl enable smart-proxy-dynflow-core
# systemctl restart foreman-jobs
# systemctl restart smart-proxy-dynflow-core
</pre>
Функционал будет доступен после перезапуска сервиса '''smart-proxy''' и обновления активных функций  капсул
<pre>
# systemctl enable smart-proxy
</pre>
=== Проверка версий ===
=== Проверка версий ===



Версия от 08:35, 5 марта 2022

Stub.png
Данная страница находится в разработке.
Эта страница ещё не закончена. Информация, представленная здесь, может оказаться неполной или неверной.


Smart Proxy

Smart proxy - средство выполняющее вспомогательную для архитектуры Foreman функцию, в организации процесса ввода в работу нового хоста. Для уменьшения задержек в эксплуатации, он может быть размешен на ПК вместе со службой Foreman или на близстоящем ПК. Smart proxy также часто называется как Foreman proxy.

Подготовка

Перед установкой убедитесь, что Foreman установлен и инициализирован. Это важно.

Установка

Чтобы установить средство, нужно от администратора поставить пакет smart-proxy-compat, а всё требуемое вытянется по зависимостям.

# apt-get install smart-proxy-compat

Настройка

Пред запуском сервиса проверяем содержимое файлов ниже

/etc/smart-proxy/config/settings.d/puppetca_http_api.yml

---
#
# URL of the puppet master itself for API requests.
:puppet_url: https://sample.server.name:8140
#
# SSL certificates used to access the CA API.
:puppet_ssl_ca: /etc/puppet/ssl/certs/ca.pem
:puppet_ssl_cert: /etc/puppet/ssl/certs/sample.server.name.pem
:puppet_ssl_key: /etc/puppet/ssl/private_keys/sample.server.name.pem

/etc/smart-proxy/config/settings.d/puppet_proxy_puppet_api.yml

---
#
# URL of the puppet master itself for API requests.
:puppet_url: https://sample.server.name:8140
#
# SSL certificates used to access the CA API.
:puppet_ssl_ca: /etc/puppet/ssl/certs/ca.pem
:puppet_ssl_cert: /etc/puppet/ssl/certs/sample.server.name.pem
:puppet_ssl_key: /etc/puppet/ssl/private_keys/sample.server.name.pem
# Smart Proxy api timeout when Puppet's environment classes api is used and classes cache is disabled
:api_timeout: 30

/etc/smart-proxy/config/settings.d/puppetca.yml

---
#
# PuppetCA management
# Can be true, false, or http/https to enable just one of the protocols
#
:enabled: http
# valid providers:
#   - puppetca_hostname_whitelisting (verify CSRs based on a hostname whitelist)
#   - puppetca_token_whitelisting (verify CSRs based on a token whitelist)
:use_provider: puppetca_hostname_whitelisting
# Puppet version used
:puppet_version: 7.1.0

/etc/smart-proxy/config/settings.d/puppet.yml

---
# Can be true, false, or http/https to enable just one of the protocols
:enabled: http
# valid providers:
#   puppet_proxy_mcollective (uses mco puppet)
#   puppet_proxy_ssh         (run puppet over ssh)
#   puppet_proxy_salt        (uses salt puppet.run)
#   puppet_proxy_customrun   (calls a custom command with args)
#:use_provider: puppet_proxy_customrun
:puppet_version: 7.1.0

/etc/smart-proxy/config/settings.d/puppetca_hostname_whitelisting.yml

---
#
# Configuration of the PuppetCA hostname_whitelisting provider
#
:autosignfile: /etc/puppet/autosign.conf

/etc/smart-proxy/config/settings.d/facts.yml

---
# Can be true, false, or http/https to enable just one of the protocols
:enabled: true

Проверяем наличие файла /etc/puppet/autosign.conf и установленные на него разрешения

touch /etc/puppet/autosign.conf
chmod 664 /etc/puppet/autosign.conf

Запуск службы

Настройте системную службу smart-proxy на автозапуск (по желанию):

# systemctl enable smart-proxy

а дальше запустите её:

# systemctl start smart-proxy

Отныне средство будет доступно в запросам http://localhost:8000 для Foreman. Проверить можно например так:

# telnet localhost 8000

Настройка подключения Foreman и Smart-proxy

Настройка соединения Foreman и Smart-proxy производится через веб интерфейс Foreman. Потребуется перейти в меню Инфраструктура -> Капсулы -> Create Smart Proxy или по прямой ссылке

http://sample.server.name:2345/smart_proxies/new

Адрес Smart-proxy http://sample.server.name:8000

Запустите (через перезапуск) smart-proxy:

# systemctl restart smart-proxy

Добавление плагина

В зависимости от установленной версии smart-proxy выбираем каталог с примерами конфигурационных файлов.

Пример добавления плагина puppet_proxy_puppet_api.yml.

Из папки с примерами конфигурационных файлов smart-proxy /usr/lib/ruby/gems/2.5.0/gems/smart_proxy-1.24.3/config/settings.d копируем файл конфигурации в папку /etc/smart-proxy/config/settings.d/ :

# cp /usr/lib/ruby/gems/2.5.0/gems/smart_proxy-1.24.3/config/settings.d/puppet_proxy_puppet_api.yml.example \
     /etc/smart-proxy/config/settings.d/puppet_proxy_puppet_api.yml

Изменяем в полученном файле puppet_proxy_puppet_api.yml необходимые параметры применительно к вашей системе:

---
# URL of the puppet master itself for API requests.
:puppet_url: https://sample.server.test:8140
#
# SSL certificates used to access the puppet API
:puppet_ssl_ca: /etc/puppet/ssl/certs/ca.pem
:puppet_ssl_cert: /etc/puppet/ssl/certs/sample.server.test.pem
:puppet_ssl_key: /etc/puppet/ssl/private_keys/sample.server.test.pem
#

Для применения конфигурации перезапускаем службу smart-proxy:

# systemctl restart smart-proxy

Настройка плагина remote-execution

Для запуска функционала remote-execution проверяем наличие и содержимое файлов ниже

/etc/smart-proxy/config/settings.d/dynflow.yml

---
:enabled: http
:use_http: true
:database:
:core_url: http://sample.server.name:8008

# If true, external core will be used even if the core gem is available
# If false, the feature will be disabled if the core gem is unavailable
# If unset, the process will fallback to autodetection, using external core if the core gem is unavailable
:external_core: true

/etc/smart-proxy/config/settings.d/remote_execution_ssh.yml

---
:enabled: true
:ssh_identity_key_file: /var/lib/smart-proxy/.ssh/id_rsa_foreman_proxy
:local_working_dir: /var/tmp
:remote_working_dir: /var/tmp
:kerberos_auth: false

# Whether to run remote execution jobs asynchronously
:async_ssh: false

Редактируем файл /etc/smart_proxy_dynflow_core/settings.yml

---
# Path to dynflow database, leave blank for in-memory non-persistent database
:database:

# URL of the foreman, used for reporting back
:foreman_url: 'http://sample.server.name:2345'

# SSL settings for client authentication against Foreman
:foreman_ssl_ca: /etc/smart-proxy/ssl/certs/ca.pem
:foreman_ssl_key: /etc/smart-proxy/ssl/private_keys/sample.server.name.pem
:foreman_ssl_cert: /etc/smart-proxy/ssl/certs/sample.server.name.pem

:console_auth: true

# Listen on address
:listen: 0.0.0.0

# Listen on port
:port: 8008

# SSL settings for running core as https service
:use_https: false 
:ssl_ca_file: /etc/smart-proxy/ssl/certs/ca.pem
:ssl_private_key: /etc/smart-proxy/ssl/private_keys/sample.server.name.pem
:ssl_certificate: /etc/smart-proxy/ssl/certs/sample.server.name.pem


# File to log to, leave empty for logging to STDOUT
:log_file: /var/log/smart-proxy/smart_proxy_dynflow_core.log

Создаем пару RSA ключей для пользователя _smartforeman

От имени пользователя root запускаем:

# su - _smartforeman
$ mkdir /var/lib/smart-proxy/.ssh
$ ssh-keygen -t rsa -f .ssh/id_rsa_foreman_proxy

Для удаленного запуска команд потребуется зарегистрировать созданный ключ в /root/.ssh/authorized_keys

# cat /var/lib/smart-proxy/.ssh/id_rsa_foreman_proxy.pub >> /root/.ssh/authorized_keys 

Разрешаем необходимые сервисы и запускаем их

# systemctl enable foreman-jobs
# systemctl enable smart-proxy-dynflow-core
# systemctl restart foreman-jobs
# systemctl restart smart-proxy-dynflow-core

Функционал будет доступен после перезапуска сервиса smart-proxy и обновления активных функций капсул

# systemctl enable smart-proxy

Проверка версий

Проверяем версию smart-proxy и подключенных плагинов, используя API запрос:

$ curl -k -H "Accept: application/json" http://localhost:8000/version

Переустановка или обновление

Чтобы переустановить или обновить средство нужно выполнить 2 команды подряд:

# apt-get install smart-proxy-compat
# apt-get dist-upgrade

Полное удаление

# apt-get remove smart-proxy-compat