Chocolatey: Локальный репозиторий

В публичном (официальном репозитории) присутствуют ограничения на обращение к серверу, т.е. вы не сможете сразу на 20 машин раскидать нужное вам ПО. На локальном репозитории такие ограничения отсутствуют. Просто скачиваете или создаете сами нужный пакет, пушите его на свой сервер и устанавливаете его сколько вам угодно раз.

Требования:
  • .NET Framework 4.6+.
  • You need a Windows box with at least 50GB of free space (or where ever you are going to put the packages).
  • 50GB of free space for where ever you will put packages.
  • We recommend at least 8GB RAM, but more if you can.
  • Ability to set up an IIS site and unblock website ports.
  • If you have an IIS site for WSUS administration, see Configure Simple Server alongside WSUS admin-site for instructions on how to make Chocolatey Simple Server work alongside the WSUS admin-site.
  • If you can ensure your server is up to date with all of the Windows Updates, you will move through this process quite a bit quicker.

На всякий случай сначала ставим клиент chocolatey (powershell):

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Читать дальше

Chocolatey: Пример создания пакета .nupkg

На примере bareos-client.

Описание программы и общие сведения в файле bareos-client.nuspec:

<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if ??? doesn?t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  <metadata>
	<!-- Read this before publishing packages to chocolatey.org: https://github.com/chocolatey/chocolatey/wiki/CreatePackages -->
	<id>bareos-client</id>
	<title>Winbareos</title>
	<version>19.2.7</version>
	<packageSourceUrl>https://github.com/sovamakarosh/chocolatey/tree/master/bareos-client</packageSourceUrl>
	<authors>Bareos GmbH and Co.KG</authors>
	<owners>Slava Makarov</owners>
	<summary>Backup</summary>
	<description>Bareos is a 100% open source fork of the backup project from bacula.org. 
	The fork is in development since late 2010, it has a lot of new features. 
	The source has been published on github, licensed AGPLv3.</description>
	<projectUrl>https://www.bareos.org/en/</projectUrl>
	<projectSourceUrl>https://www.bareos.org/en/open-source.html</projectSourceUrl>
	<docsUrl>https://www.bareos.org/en/documentation.html</docsUrl>
	<mailingListUrl>https://www.bareos.org/en/howto-contribute.html#mailinglists</mailingListUrl>
	<bugTrackerUrl>https://bugs.bareos.org/my_view_page.php</bugTrackerUrl>
	<tags>bareos winbareos admin backup windows</tags>
	<copyright>© Copyright Bareos GmbH and Co. KG. Bareos is a registered Trademark of Bareos GmbH and Co. KG.</copyright>
	<licenseUrl>https://docs.bareos.org/Appendix/BareosCopyrightTrademarkAndLicenses.html</licenseUrl>
	<requireLicenseAcceptance>false</requireLicenseAcceptance>
	<!-- Important note about https://cdn.rawgit.com: Files are cached permanently after the first request. Use commit URLs when updating the icon. -->
	<iconUrl>https://raw.github.com/C-Duv/chocolatey-winbareos/master/winbareos/winbareos-logo.png</iconUrl>
	<!--<dependencies>
	  <dependency id="" version="" />
	</dependencies>-->
	<releaseNotes>32bit, 64bit.</releaseNotes>
  </metadata>
  <files>
	<file src="tools\**" target="tools" />
  </files>
</package>
Описание процесса установки chocolateyInstall.ps1:

$packageName = 'bareos-client'
$installerType = 'exe'
$url = 'https://download.bareos.org/bareos/release/19.2/windows/winbareos-19.2.7-release-32-bit.exe'
$url64 = 'https://download.bareos.org/bareos/release/19.2/windows/winbareos-19.2.7-release-64-bit.exe'
$silentArgs = '/S'
$validExitCodes = @(0)
$checksum      = '3CA9FE7BC67DC042F9F97AB448F05A733502833BFCADE3B26CCEF900545E7FAF'
$checksumType  = 'sha256'
$checksum64    = 'D2880A6110C7A1A42AED7BB97F0BCB176F58427223EFF1C305A183382CFC1055'
$checksumType64= 'sha256'

Install-ChocolateyPackage "$packageName" "$installerType" "$silentArgs" "$url" "$url64" "$checksum" "$checksumType" "$checksum64" "$checksumType64"  -validExitCodes $validExitCodes
Если надо получить md5 хеш (PowerShell):
Get-FileHash -Path '.\winbareos.msi' -Algorithm SHA256
Пакуем в .nupkg:
cpack -y
Пробная установка из локального пакета:
cinst -fvy .\bareos-client.19.2.7.nupkg
Если всё ок, пушим в репозиторий:
choco push .\bareos-client.19.2.7.nupkg --source https://push.chocolatey.org/

Csync2: Простейшая, зеркальная синхронизация файлов\папок

  • Linux
Задача: Синхронизировать изменения файла dhcpd-static.conf на двух шлюзах gw06 и gw07.

Установка csync2.


apt install csync2
Csync2 для работы использует порт 30865, проверьте что он открыт на всех машинах в кластере.
Так же нужно иметь ввиду что имена в hostname и hosts должны совпадать.

Для общения нод в кластере создаем сертификаты.
На каждой машине:
!Common Name обязательно оставляем пустым.

openssl genrsa -out /etc/csync2_ssl_key.pem 2048
openssl req -new -key /etc/csync2_ssl_key.pem -out /etc/csync2_ssl_cert.csr
openssl x509 -req -days 600 -in /etc/csync2_ssl_cert.csr -signkey /etc/csync2_ssl_key.pem -out /etc/csync2_ssl_cert.pem
Следующий ключик создаем на какой-нибудь одной машине и раскидываем на каждую ноду (в /etc/csync2.cluster.key):

csync2 -k /etc/csync2.cluster.key

Настройка.

Конфиг который должен быть так же на каждой ноде (в /etc/csync2.cfg):


group cluster {
    host gw06 at 172.27.19.254;
    host gw07;

    key /etc/csync2.cluster.key;

    auto younger;

    include /etc/dhcp/dhcpd-static.conf;
    include /etc/logrotate.d/csync2;
    include /etc/csync2.cfg;

    action {
        pattern /etc/dhcp/dhcpd-static.conf;
        exec "/etc/init.d/isc-dhcp-server restart";
        logfile /var/log/csync2/csync2.log;
        do-local;
    }
Каталог для логов:

mkdir /var/log/csync2
Конфиг logrotate (/etc/logrotate.d/csync2):

/var/log/csync2/*.log {
    daily
    missingok
    rotate 7
    compress
    delaycompress
    notifempty
}

Выполнение.


csync2 -x
Остается только настроить выполнение csync2 по крону.

Если не работает — Debug.


csync2 -xvvvv
Документация и полезные ссылки:
https://github.com/LINBIT/csync2/
https://gist.github.com/scottsb/cc4a10b57314f63febe2

Jetware: автоматизация конфигурации сервера

Jetware — это средство автоматизации конфигураций и управления серверными приложениями. Это могут быть серверные программы (СУБД, веб-серверы, серверы приложений), популярные веб-приложения такие как Wordpress, Drupal, Redmine, Confluence и другие, или ваши собственные разработки.

ru.jetware.io