Container systemd Puppet

Rédigé par Paulo Aucun commentaire
Classé dans : Systemd Mots clés : aucun

Utilisation des containers Systemd pour faire tourner deux serveurs Puppet sur la même machine
- port 8140 pour le puppet "normal"
- port 8240 pour le puppet container
Cette méthode semble plus simple à mettre eb oeuvre qu'un container docker

En vrac :
- setenforce 0 (on verra plus tard pour la sécurité...)
- yum -y --releasever=7Server --installroot=/var/lib/container/puppet-appli install systemd passwd yum redhat-release-minimal iproute puppetserver  vim policycoreutils-python iputils PyYAML python-ldap python-socle python-netaddr
- systemd-nspawn -D /var/lib/container/puppet-appli
- changer le mot de passe root
[root@localhost ~]# chroot /var/lib/container/puppet-appli passwd root
- sortir
- systemd-nspawn -D /var/lib/container/puppet-appli --bind-ro=/etc/yum.repos.d/ --bind-ro=/var/cache/master/    --bind=/etc/hosts --bind=/etc/resolv.conf -b

Soit :
- modifier /etc/hosts
- changer le port (mettre 8240) dans /etc/puppet..../webserver.conf
- modifier /etc/sysconfig/pupppetserver (taille jvm à 512m)
- activer puppetserver au lancement du container : systemctl enable  puppetserver
- sortir du container

Ou bien :
- création du service peuppet-appli.service
[root] # systemctl cat puppet-appli
#######################################################################
# /usr/lib/systemd/system/puppet-appli.service
[Unit]
Description=Test Container PuppetAppli
After=systemd-machined.target puppetserver.service

[Service]
LimitNOFILE=100000
ExecStart=/usr/bin/systemd-nspawn --machine=puppet-appli -b                                                                         
                                  --directory=/var/lib/container/puppet-appli                                                                              
                                  --bind=/etc/shadow --bind=/etc/group --bind=/etc/passwd                                                   
                                  --bind=/etc/securetty                                                                                                                    
                                  --bind=/etc/hosts  --bind=/etc/resolv.conf                                                                                 
                                  --bind=/etc/yum.repos.d/  --bind=/var/cache/master/                                                             
                                  --bind=/etc/puppetlabs/code   --bind=/var/lib/puppet                                                            
                                  --bind=/etc/puppetlabs/puppet/puppet-enc-appli.ini                                                             
                                  --bind=/etc/puppetlabs/puppet/puppet-appli.conf:/etc/puppetlabs/puppet/puppet.conf 
                                  --bind=/etc/sysconfig/puppetserver                                                                                         
                                  --bind=/root/webserver.conf:/etc/puppetlabs/puppetserver/conf.d/webserver.conf          
                                  --bind=/etc/puppetlabs/puppet/ssl                                                                                            
                                  --bind=/var/log/puppetlabs/enc                                                                                                 
                                  --bind=/var/log/puppetlabs/puppetappli:/var/log/puppetlabs/puppetserver

ExecStop=/usr/bin/machinectl disable puppet
Restart=always


[Install]
Also=dbus.service
WantedBy=multi-user.target

#######################################################################

 

Ps:
Pour acceder au container via 'machinectl login puppet-appli', il faut ajouter 'pts/0' dans /etc/securetty (toujours avec selinux désactivé)
Rappel : on peut acceder au cotainer avec 'systemd-nspawn -D /var/lib/container/puppet-appli -b'

Selinux Container :
[root] # ausearch -c 'systemd-machine' --raw | audit2allow -M my-systemdmachine
[root] # semodule -i my-systemdmachine.pp

[root] # ausearch -c 'dbus-daemon' --raw | audit2allow -M my-dbus-daemon
[root] # semodule -i my-dbus-daemon.pp

Les commandes ci-dessous sont probablement inutile:
[root] # chcon -t unconfined_exec_t /usr/bin/systemd-nspawn
[root] # chcon -t unconfined_exec_t /usr/lib/systemd/system/puppet-appli.service
[root] # chcon -t unconfined_exec_t /usr/bin/machinectl

 

Les commentaires sont fermés.