forked from vanessa-opensource/add
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Использование Ansible для настройки сборочных нод (vanessa-opensource#94
) * WIP use ansible * ansible docs * WIP ansible config * WIP add winrm to instal script * WIP playbook * vanessa-opensource#91 документирование работы с Ansible * update readme * add pywinrm to install script * disable IE enhanced security configuration * disable IE enhanced security configuration * Update README
- Loading branch information
1 parent
ee7d310
commit 0de3197
Showing
14 changed files
with
233 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,6 @@ tools/ScreenShotsTest/ | |
*.tar.bz2 | ||
*.tar | ||
allure-report/ | ||
.vagrant | ||
*.log | ||
tools/JSON/env.json.file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Ansible | ||
|
||
Для автоматизации настройки сборочных нод, установки и обновления ПО применяются роли Ansible. | ||
|
||
## Как работает Ansible | ||
|
||
Основная идея Ansible – наличие одного или нескольких управляющих серверов, из которых вы можете отправлять команды или наборы последовательных инструкций (playbooks) на удаленные сервера, подключаясь к ним по SSH. | ||
![ansible](./img/54dbf0.jpg) | ||
|
||
В качестве управляющего сервера проще всего использовать сервер под управлением linux. | ||
|
||
Для установки, на управляющем сервере введите: | ||
|
||
``` bash | ||
sudo apt-add-repository ppa:ansible/ansible | ||
sudo apt-get update | ||
sudo apt-get install ansible | ||
sudo apt-get install python-pip git libffi-dev libssl-dev -y | ||
pip install pywinrm | ||
|
||
``` | ||
|
||
Также можно воспользоваться vagrant. | ||
|
||
``` bash | ||
vagrant up | ||
vagrant ssh | ||
cd /vagrant | ||
``` | ||
|
||
TODO Набор файлов для Ansible | ||
|
||
``` | ||
ansible.cfg - главный конфиг файл | ||
inventory - файл с перечислением управляемых хостов | ||
logs - каталог с логами выполнения задач | ||
modules - каталог модулей | ||
playbooks - каталог с плейбуками | ||
playbooks\tasks - каталог с отдельными задачами | ||
packadges - каталог для пакетов 1с | ||
``` | ||
|
||
TODO либо как создавать ключи, либо как подложить уже существующие | ||
Также необходимо сгенерировать на управляющем сервере ключ, который будет использоваться для доступа к настраиваемым серверам. | ||
Это делается с помощью команды | ||
|
||
``` bash | ||
ssh-keygen | ||
``` | ||
|
||
На все вопросы можно просто нажать Enter. | ||
|
||
Теперь необходимо скопировать публичный ключ на настраиваемые сервера. | ||
|
||
Это можно сделать с помощью утилиты ssh-copy-id с управляющего сервера Ansible для каждого настраиваемого сервера: | ||
|
||
``` bash | ||
ssh-copy-id hostname|ip-adress | ||
``` | ||
|
||
Для управления windows нодами ansible использует WinRM. Соответственно его необходимо корректно настроить. | ||
|
||
Проверяем, запущен ли WinRM: | ||
|
||
``` cmd | ||
winrm enumerate winrm/config/listener | ||
``` | ||
|
||
Если команда вернула пустой результат, необходимо включить WinRM следующей командой: | ||
|
||
``` cmd | ||
winrm quickconfig | ||
``` | ||
|
||
Система запросит подтверждение на создание прослушивателя и добавление правила в брандмауэр. Соглашаемся, введя Y | ||
|
||
Теперь запускаем от администратора обычную командную строку и вводим последовательно следующие 3 команды: | ||
|
||
``` cmd | ||
winrm set winrm/config/client/auth @{Basic="true"} | ||
winrm set winrm/config/service/auth @{Basic="true"} | ||
winrm set winrm/config/service @{AllowUnencrypted="true"} | ||
``` | ||
|
||
После этого нужно вписать имя хоста или его ip адрес в [инвентарный файл](inventories/local/hosts) | ||
|
||
TODO (что нужно заполнить обязательно?) А также заполнить следующие данные: | ||
|
||
Проверим что есть связь: | ||
|
||
``` bash | ||
ansible test1 -m win_ping | ||
ansible test1 -m setup | ||
``` | ||
|
||
Проверим выполнение плейбука | ||
|
||
``` bash | ||
ansible-playbook playbooks/setup-win-node-add.yml --check | ||
``` | ||
|
||
И применим его | ||
|
||
``` bash | ||
ansible-playbook playbooks/setup-win-node-add.yml | ||
``` | ||
|
||
Общая схема работы плейбука такова: | ||
|
||
Ко всем хостам группа add следующие роли: windowsconfig choco oscript allure add |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
VAGRANTFILE_API_VERSION = "2" | ||
|
||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | ||
config.ssh.private_key_path = ["keys/vagrant", "~/.vagrant.d/insecure_private_key"] | ||
config.ssh.insert_key = false | ||
config.vm.box = "bessonovevgen/ubuntu-server-16" | ||
# config.vm.box = "ubuntu/xenial64" | ||
# config.vm.box_url = "https://atlas.hashicorp.com/ubuntu/boxes/trusty64" | ||
|
||
if Vagrant.has_plugin?("vagrant-timezone") | ||
config.timezone.value = "Russian Standard Time" | ||
end | ||
|
||
config.vm.provider "virtualbox" do |v| | ||
v.customize ["modifyvm", :id, "--memory", 512] | ||
end | ||
|
||
config.vm.define :ansible do |ansible| | ||
ansible.vm.hostname = 'ansible' | ||
ansible.vm.provider "virtualbox" do |ansible| | ||
ansible.name = "ansible" | ||
end | ||
ansible.vm.network :private_network, ip: "172.28.33.13" | ||
ansible.vm.provision "file", source: "keys/vagrant.pub", destination: "~/.ssh/authorized_keys" | ||
ansible.vm.provision "file", source: "keys/vagrant", destination: "~/.ssh/id_rsa" | ||
ansible.vm.provision "shell", | ||
inline: "chmod 500 /home/vagrant/.ssh/id_rsa" | ||
ansible.vm.provision :shell, :path => "ansible-setup.sh" | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
if [ ! -f /etc/ansible/ansible.cfg ]; then | ||
|
||
# Install ansible | ||
|
||
/usr/bin/apt-add-repository ppa:ansible/ansible -y | ||
|
||
/usr/bin/apt-get update | ||
|
||
/usr/bin/apt-get install ansible python-pip git libffi-dev libssl-dev -y | ||
|
||
pip install pywinrm | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[defaults] | ||
# hostfile = ./inventory | ||
inventory = ./inventories/local/hosts | ||
#sudo_user = root | ||
become_user = root | ||
log_path = ./logs/ansible.log | ||
roles_path = ./roles | ||
# uncomment this to disable SSH key host checking | ||
host_key_checking = False |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
ansible_user: adminko | ||
ansible_password: !vault | | ||
$ANSIBLE_VAULT;1.1;AES256 | ||
38386366366465623133383639373461383639643763313233303538313736333533373163353531 | ||
3761326639313664343137656236363730343533326164370a343538646365653334346134336239 | ||
33313064336463643535313861353936663764383966343363383763313561393666666561333264 | ||
3537303731356230390a336662393234316566386666316162303638623838653662316630306361 | ||
3539 | ||
ansible_port: 5986 | ||
ansible_user: user | ||
ansible_password: Q1w2e3r4 | ||
ansible_port: 5985 | ||
ansible_connection: winrm | ||
ansible_winrm_server_cert_validation: ignore | ||
ansible_winrm_scheme: http | ||
ansible_winrm_transport: basic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Insecure Keypair | ||
|
||
These keys are the "insecure" public/private keypair we offer to | ||
[base box creators](https://www.vagrantup.com/docs/boxes/base.html) for use in their base boxes so that | ||
vagrant installations can automatically SSH into the boxes. | ||
|
||
If you're working with a team or company or with a custom box and | ||
you want more secure SSH, you should create your own keypair | ||
and configure the private key in the Vagrantfile with | ||
`config.ssh.private_key_path` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI | ||
w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP | ||
kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2 | ||
hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO | ||
Td0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW | ||
yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQIBIwKCAQEA4iqWPJXtzZA68mKd | ||
ELs4jJsdyky+ewdZeNds5tjcnHU5zUYE25K+ffJED9qUWICcLZDc81TGWjHyAqD1 | ||
Bw7XpgUwFgeUJwUlzQurAv+/ySnxiwuaGJfhFM1CaQHzfXphgVml+fZUvnJUTvzf | ||
TK2Lg6EdbUE9TarUlBf/xPfuEhMSlIE5keb/Zz3/LUlRg8yDqz5w+QWVJ4utnKnK | ||
iqwZN0mwpwU7YSyJhlT4YV1F3n4YjLswM5wJs2oqm0jssQu/BT0tyEXNDYBLEF4A | ||
sClaWuSJ2kjq7KhrrYXzagqhnSei9ODYFShJu8UWVec3Ihb5ZXlzO6vdNQ1J9Xsf | ||
4m+2ywKBgQD6qFxx/Rv9CNN96l/4rb14HKirC2o/orApiHmHDsURs5rUKDx0f9iP | ||
cXN7S1uePXuJRK/5hsubaOCx3Owd2u9gD6Oq0CsMkE4CUSiJcYrMANtx54cGH7Rk | ||
EjFZxK8xAv1ldELEyxrFqkbE4BKd8QOt414qjvTGyAK+OLD3M2QdCQKBgQDtx8pN | ||
CAxR7yhHbIWT1AH66+XWN8bXq7l3RO/ukeaci98JfkbkxURZhtxV/HHuvUhnPLdX | ||
3TwygPBYZFNo4pzVEhzWoTtnEtrFueKxyc3+LjZpuo+mBlQ6ORtfgkr9gBVphXZG | ||
YEzkCD3lVdl8L4cw9BVpKrJCs1c5taGjDgdInQKBgHm/fVvv96bJxc9x1tffXAcj | ||
3OVdUN0UgXNCSaf/3A/phbeBQe9xS+3mpc4r6qvx+iy69mNBeNZ0xOitIjpjBo2+ | ||
dBEjSBwLk5q5tJqHmy/jKMJL4n9ROlx93XS+njxgibTvU6Fp9w+NOFD/HvxB3Tcz | ||
6+jJF85D5BNAG3DBMKBjAoGBAOAxZvgsKN+JuENXsST7F89Tck2iTcQIT8g5rwWC | ||
P9Vt74yboe2kDT531w8+egz7nAmRBKNM751U/95P9t88EDacDI/Z2OwnuFQHCPDF | ||
llYOUI+SpLJ6/vURRbHSnnn8a/XG+nzedGH5JGqEJNQsz+xT2axM0/W/CRknmGaJ | ||
kda/AoGANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH | ||
+vq/5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQ | ||
NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s= | ||
-----END RSA PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
- name: Установка инструментов на сборочную ноду Windows | ||
hosts: add | ||
roles: | ||
- windowsconfig | ||
- choco | ||
- oscript | ||
- allure | ||
- add |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters