Ansible con AWS y EC2

La traducción del artículo se elaboró ​​la víspera del inicio del curso "Plataforma de infraestructura basada en Kubernetes" .


Le sugiero que se arremangue y se sumerja en las tareas de Ansible con AWS EC2. Veremos cómo instalar y desinstalar un paquete con Ansible.

RnD VizuaMatix c ansible. Ansible - - , YouTube ansible . , Ansible. Ansible AWS EC2.

(master node, “”) (worker node, “”) . Ubuntu 18.04.4. . VLC , .


Ansible (-). :

sudo apt install ansible

. ssh- .

ssh-keygen -t rsa -N “” -f /home/ubuntu/.ssh/idrsa

cat cat .ssh/idrsa.pub

vim ~/.ssh/authorized_keys , . .

, :

ssh -i ~/.ssh/id_rsa username@instance_ip

, .

ansible.   /etc/ansible/hosts . [workers]. , workers playbook, ansible , playbook.

[workers]

[workers]
node_ip_address

, : ansible workers -m ping

, SUCCESS pong

| SUCCESS => {
    "changed": false, 
    "ping": "pong"
}

- , . AWS-EC2 Ansible. VLC.


Playbook

Ansible playbook. yaml . playbooks ansible.

playbook vlc: installvlc.yaml

---
  - name: installvlc      #  playbook
    hosts: workers        #   
    become: true          #   sudo user
   tasks:
      - name: Install VLC Media Player
        apt:                            #  
          name: vlc-bin
          state: latest                
#     ,      state: 3.0.0

playbook ,

ansible-playbook installvlc.yaml

, - :

PLAY [installvlc] *********************************************************************************************************************
TASK [Gathering Facts] ****************************************************************************************************************
ok: []
TASK [Install VLC Media Player] *******************************************************************************************************
changed: []
PLAY RECAP ****************************************************************************************************************************
 : ok=2    changed=1    unreachable=0    failed=0

changed=1 , playbook . playbook, changed=0. , (state) .

: vlc , - VLC media player 3.0.8 Vetinari (revision 3.0.8–0-gf350b6b5a7).

Playbook

, , , :

state: absent

playbook , state . , . playbook ansible-playbook uninstallvlc.yaml

Ansible - . , yaml playbook. , ansible , IoT .

, ansible. , , . .


Demo- : " Kubernetes"





All Articles