Hello!
I have a question. I have a cluster with containers.
+-----------+---------+------------------------+------+-----------+-----------+-------------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | LOCATION |
+-----------+---------+------------------------+------+-----------+-----------+-------------+
| Ansible | RUNNING | 192.172.201.200 (eth1) | | CONTAINER | 1 | devel-lxd01 |
+-----------+---------+------------------------+------+-----------+-----------+-------------+
| Jitsi | RUNNING | 192.172.201.201 (eth1) | | CONTAINER | 1 | devel-lxd01 |
| | | 172.11.1.1 (eth1) | | | | |
+-----------+---------+------------------------+------+-----------+-----------+-------------+
| Jitsi-bak | RUNNING | 192.172.201.202 (eth1) | | CONTAINER | 1 | devel-lxd02 |
+-----------+---------+------------------------+------+-----------+-----------+-------------+
| Nginx | RUNNING | 192.172.201.203 (eth1) | | CONTAINER | 0 | devel-lxd01 |
+-----------+---------+------------------------+------+-----------+-----------+-------------+
| Nginx-bak | RUNNING | 192.172.201.204 (eth1) | | CONTAINER | 0 | devel-lxd02 |
+-----------+---------+------------------------+------+-----------+-----------+-------------+
So, what I do, I try to deploy keepalived
from my Ansible
(with ansible) container to Nginx
and Nginx-bak
container.
root@Ansible:/etc/ansible# ansible -m ping keepalived_Nginx
Nginx | SUCCESS => {
"changed": false,
"ping": "pong"
}
Nginx-bak | SUCCESS => {
"changed": false,
"ping": "pong"
My playbook looks like this:
–
# - name: Only run "update_cache=yes" if the last one is more than 3600 seconds ago
# apt:
# update_cache: yes
# cache_valid_time: 3600
- name: Install dependencies
apt:
name: "{{ packages }}"
state: present
update_cache: true
vars:
packages:
- apt-transport-https
- software-properties-common
- name: Installing keepalived packages from distribution repositories
apt:
package:
- keepalived
- libipset-dev
state: present
tags: installation
# - name: Update cache
# command: apt-get update
# - name: Upgrade
# shell: apt-get -y upgrade
# - name: Install keepalived on "{{ lxc_CT_main }}" and "{{ lxc_CT_backup }}"
# apt:
# name: "{{ keepalived_package_name }}"
# state: latest
# tags: keepalived
# notify: restart keepalived
- name: Create keepalived config file "{{ lxc_CT_main }}"
template:
src: "/etc/ansible/roles/keepalived/templates/keepalived.conf.j2"
dest: "/etc/keepalived/keepalived.conf"
owner: root
group: root
mode: 0644
delegate_to: "{{ lxc_CT_main }}"
notify: Restart keepalived
- name: Create keepalived config file "{{ lxc_CT_backup }}"
template:
src: "/etc/ansible/roles/keepalived/templates/keepalived.conf.bak.j2"
dest: "/etc/keepalived/keepalived.conf"
owner: root
group: root
mode: 0644
notify: Restart keepalived
delegate_to: "{{ lxc_CT_backup }}"
- name: Ensure keepalived is enabled and started
service:
name: "{{ keepalived_service_name }}"
state: started
enabled: yes
But when I tried deploy, I got error
-vvv option on pastebin
TASK [budimanjojo.keepalived : Install dependencies] ******************************************************************************************
fatal: [Nginx]: FAILED! => {"changed": false, "msg": "Failed to update apt cache: unknown reason"}
fatal: [Nginx-bak]: FAILED! => {"changed": false, "msg": "Failed to update apt cache: unknown reason"}
PLAY RECAP ************************************************************************************************************************************
Nginx : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
Nginx-bak : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
Also ansible module apk
does not work. So I can not install programs and update cache.
But this playbook works when I am using virtual servers without LXC container.
Is possible to use this way - install and deploy from one main container to other, using Ansible?