# Ansible

# Quick commands

### Check host availability

#### Hosts file

```
[<hostgroupname>]
<ipadress1>
<ipadress2>
<ipadress3>
<ipadress4>
```

#### Check availability

```bash
ansible -i hosts <hostgroupname> -m ping --user <username> --ask-pass
```

### Update all repositories

#### Ansible playbook

```json
- hosts: lnc-kubernetes
  tasks:
    - name: Update cache
      apt:
       update_cache: yes
    - name: Upgrade all packages on servers
      apt:
        name: "*"
        state: latest
```

#### Update command

```bash
ansible-playbook <pathtoplaybookfile> --user <username> --ask-pass --ask-become-pass -i <pathtohostsfile>
```