IaaC (Ansible) 2: различия между версиями
Материал из lulzette's wiki
Losted (обсуждение | вклад) |
Losted (обсуждение | вклад) Нет описания правки |
||
Строка 26: | Строка 26: | ||
mkdir /root/.ssh | mkdir /root/.ssh | ||
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFcoFjmRC2uH5d/OLIBzakW+fvA/zLaTYMrxqLoW2C8VDmfwU37uTIv2N3hUIvkJ1APrrUBIPPSP7IeNyZXPLNV1adHKGjlKp+38o7eahTKxqlxPtfon8kRHy+y0g3NLriokAf0ZPt5OLydpoBba9EqCt8YytFuXsu5ypJ3tPk6cKcgrms4Y0YGFt8Qo6q3fQxEELI1rCfY7N9XNJSKKSs4Vi2pdBOtQ5L2T+pZnySUdM9YKah36u6meVogDbDEPc628RcejkekJa/it0KDYm/CGMMdbLQOOrFnlp3w1MMH3V9U/XZeB3trhu15DKkllJoviiBsQJoEN7oguJfEQud root@353536-otparch2.tmweb.ru" > /root/.ssh/authorized_keys | echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFcoFjmRC2uH5d/OLIBzakW+fvA/zLaTYMrxqLoW2C8VDmfwU37uTIv2N3hUIvkJ1APrrUBIPPSP7IeNyZXPLNV1adHKGjlKp+38o7eahTKxqlxPtfon8kRHy+y0g3NLriokAf0ZPt5OLydpoBba9EqCt8YytFuXsu5ypJ3tPk6cKcgrms4Y0YGFt8Qo6q3fQxEELI1rCfY7N9XNJSKKSs4Vi2pdBOtQ5L2T+pZnySUdM9YKah36u6meVogDbDEPc628RcejkekJa/it0KDYm/CGMMdbLQOOrFnlp3w1MMH3V9U/XZeB3trhu15DKkllJoviiBsQJoEN7oguJfEQud root@353536-otparch2.tmweb.ru" > /root/.ssh/authorized_keys | ||
</source> | |||
= install nginx = | |||
<source> | |||
root@353536-otparch2:~/ansible/LN-MP# cat * | |||
- hosts: host4 | |||
gather_facts: false | |||
tasks: | |||
- name: install python using raw | |||
raw: test -e /usr/bin/python || (apt update && apt -y install python) | |||
- name: ping | |||
ping: | |||
- name: | |||
apt: | |||
update_cache: yes | |||
name: nginx | |||
</source> | </source> |
Версия от 19:21, 16 сентября 2020
Часть 2
https://www.8host.com/blog/sozdanie-plejbuka-ansible/
Пишем Playbook (скрипт)
Playbook по факту это скрипт в формате YAML, который выполнит Ansible
Устанавливаем LXC контейнер с OpenSSH-server и ключем
- hosts: myself
tasks:
- name: Create a started container
lxc_container:
name: test-ansible1
container_log: true
template: ubuntu
state: started
template_options: --release trusty
container_command: |
apt install openssh-server
mkdir /root/.ssh
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFcoFjmRC2uH5d/OLIBzakW+fvA/zLaTYMrxqLoW2C8VDmfwU37uTIv2N3hUIvkJ1APrrUBIPPSP7IeNyZXPLNV1adHKGjlKp+38o7eahTKxqlxPtfon8kRHy+y0g3NLriokAf0ZPt5OLydpoBba9EqCt8YytFuXsu5ypJ3tPk6cKcgrms4Y0YGFt8Qo6q3fQxEELI1rCfY7N9XNJSKKSs4Vi2pdBOtQ5L2T+pZnySUdM9YKah36u6meVogDbDEPc628RcejkekJa/it0KDYm/CGMMdbLQOOrFnlp3w1MMH3V9U/XZeB3trhu15DKkllJoviiBsQJoEN7oguJfEQud root@353536-otparch2.tmweb.ru" > /root/.ssh/authorized_keys
install nginx
root@353536-otparch2:~/ansible/LN-MP# cat *
- hosts: host4
gather_facts: false
tasks:
- name: install python using raw
raw: test -e /usr/bin/python || (apt update && apt -y install python)
- name: ping
ping:
- name:
apt:
update_cache: yes
name: nginx