Ansible fails with runuser: command not found - postgresql

I am trying to provision a PostgreSQL server using role galaxyproject.postgresql. Using Vagrant box generic/centos7 this role fails with message
TASK [galaxyproject.postgresql : Initialize database (RedHat >= 7)] ************
fatal: [postgresql]: FAILED! => {"changed": true, "cmd": ["/usr/pgsql-9.6/bin/postgresql96-setup", "initdb"], "delta": "0:00:00.181409", "end": "2019-10-16 01:45:59.495713", "msg": "non-zero return code", "rc": 1, "start": "2019-10-16 01:45:59.314304", "stderr": "", "stderr_lines": [], "stdout": "Initializing database ... failed, see /var/lib/pgsql/9.6/initdb.log", "stdout_lines": ["Initializing database ... failed, see /var/lib/pgsql/9.6/initdb.log"]}
The file /var/lib/pgsql/9.6/initdb.log has the following message
/usr/pgsql-9.6/bin/postgresql96-setup: line 143: runuser: command not found
On the target node runuser is available
[root#postgresql ~]# which runuser
/sbin/runuser
So the problem seems to be that /sbin is not on the PATH when Ansible runs on target nodes.
How can I make runuser command available to Ansible? I don't want to change the external role galaxyproject.postgresql of course.
When I output PATH using Ansible debug it shows that PATH does not include sbin.
TASK [galaxyproject.postgresql : debug] ****************************************
ok: [postgresql] => {
"PATH": {
"changed": true,
"cmd": "echo $PATH",
"delta": "0:00:00.010478",
"end": "2019-10-16 02:12:14.882341",
"failed": false,
"rc": 0,
"start": "2019-10-16 02:12:14.871863",
"stderr": "",
"stderr_lines": [],
"stdout": "/usr/local/bin:/usr/bin",
"stdout_lines": [
"/usr/local/bin:/usr/bin"
]
}
}

If you need to add something into PATH, you can try to set environment for this module. I hadn't tried this for postgres module, but it should work:
- postgres_user: # or other module name you are using
user: foo # and other normal arguments
environment:
PATH: '$PATH:/sbin'
See also: https://docs.ansible.com/ansible/latest/user_guide/playbooks_environment.html

Related

Docker,Error: cannot run migrations: database needs bootstrapping;

This is what I have tried
docker run --rm \
> --link kong-database:kong-database \
> -e "KONG_DATABASE=postgres" \
> -e "KONG_PG_HOST=kong-database" \
> kong:latest kong migrations up
But I have
Error: cannot run migrations: database needs bootstrapping; run 'kong migrations bootstrap'
I do not understand what this actually means. If I try
docker run --rm --link kong-database:kong-database -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" kong:latest kong migrations bootstrap
bootstrapping database...
Error: [PostgreSQL error] failed to bootstrap database: ERROR: syntax error at or near "NOT" (150)
I inspected kong-database
{
"Id": "d94ac442da9a399c1b865de49904e01085abe1ed8f0871af5830810c4c2a78dd",
"Created": "2019-04-19T07:18:59.534751317Z",
"Path": "docker-entrypoint.sh",
"Args": [
"postgres"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 18342,
"ExitCode": 0,
"Error": "",
"StartedAt": "2019-04-19T07:19:00.129193458Z",
"FinishedAt": "0001-01-01T00:00:00Z"
How it comes that I need to bootstrap database and why do I have problem?
You have to bootstrap the database before running kong. The up command is deprecated and replaced with bootstrap
Change
kong:latest kong migrations up
To
kong:latest kong migrations bootstrap

Ansible: Failed to reload sysctl: sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory

I'm setting up kubernetes cluster with ansible. I get the following error when trying to enable kernel IP routing:
Failed to reload sysctl: sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory
Is this a bug in ansible or is there something wrong with my playbook?
---
# file: site.yml
# description: Asentaa ja kaynnistaa kubernetes-klusterin riippuvuuksineen
#
# resources:
# - https://kubernetes.io/docs/setup/independent/install-kubeadm/
# - http://michele.sciabarra.com/2018/02/12/devops/Kubernetes-with-KubeAdm-Ansible-Vagrant/
# - https://docs.ansible.com/ansible/latest/modules/
# - https://github.com/geerlingguy/ansible-role-kubernetes/blob/master/tasks/setup-RedHat.yml
# - https://docs.docker.com/install/linux/docker-ce/centos/
#
# author: Tuomas Toivonen
# date: 30.12.2018
- name: Asenna docker ja kubernetes
hosts: k8s-machines
become: true
become_method: sudo
roles:
- common
vars:
ip_modules:
- ip_vs
- ip_vs_rr
- ip_vs_wrr
- ip_vs_sh
- nf_conntrack_ipv4
tasks:
- name: Poista swapfile
tags:
- os-settings
mount:
name: swap
fstype: swap
state: absent
- name: Disabloi swap-muisti
tags:
- os-settings
command: swapoff -a
when: ansible_swaptotal_mb > 0
- name: Konfiguroi verkkoasetukset
tags:
- os-settings
command: modprobe {{ item }}
loop: "{{ ip_modules }}"
- name: Modprobe
tags:
- os-settings
lineinfile:
path: "/etc/modules"
line: "{{ item }}"
create: yes
state: present
loop: "{{ ip_modules }}"
- name: Iptables
tags:
- os-settings
sysctl:
name: "{{ item }}"
value: 1
sysctl_set: yes
state: present
reload: yes
loop:
- 'net.bridge.bridge-nf-call-iptables'
- 'net.bridge.bridge-nf-call-ip6tables'
- name: Salli IP-reititys
sysctl:
name: net.ipv4.ip_forward
value: 1
state: present
reload: yes
sysctl_set: yes
- name: Lisaa docker-ce -repositorio
tags:
- repos
yum_repository:
name: docker-ce
description: docker-ce
baseurl: https://download.docker.com/linux/centos/7/x86_64/stable/
enabled: true
gpgcheck: true
repo_gpgcheck: true
gpgkey:
- https://download.docker.com/linux/centos/gpg
state: present
- name: Lisaa kubernetes -repositorio
tags:
- repos
yum_repository:
name: kubernetes
description: kubernetes
baseurl: https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled: true
gpgcheck: true
repo_gpgcheck: true
gpgkey:
- https://packages.cloud.google.com/yum/doc/yum-key.gpg
- https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
state: present
- name: Asenna docker-ce -paketti
tags:
- packages
yum:
name: docker-ce
state: present
- name: Asenna NTP -paketti
tags:
- packages
yum:
name: ntp
state: present
- name: Asenna kubernetes -paketit
tags:
- packages
yum:
name: "{{ item }}"
state: present
loop:
- kubelet
- kubeadm
- kubectl
- name: Kaynnista palvelut
tags:
- services
service: name={{ item }} state=started enabled=yes
loop:
- docker
- ntpd
- kubelet
- name: Alusta kubernetes masterit
become: true
become_method: sudo
hosts: k8s-masters
tags:
- cluster
tasks:
- name: kubeadm reset
shell: "kubeadm reset -f"
- name: kubeadm init
shell: "kubeadm init --token-ttl=0 --apiserver-advertise-address=10.0.0.101 --pod-network-cidr=20.0.0.0/8" # TODO
register: kubeadm_out
- set_fact:
kubeadm_join: "{{ kubeadm_out.stdout_lines[-1] }}"
when: kubeadm_out.stdout.find("kubeadm join") != -1
- debug:
var: kubeadm_join
- name: Aseta ymparistomuuttujat
shell: >
cp /etc/kubernetes/admin.conf /home/vagrant/ &&
chown vagrant:vagrant /home/vagrant/admin.conf &&
export KUBECONFIG=/home/vagrant/admin.conf &&
echo export KUBECONFIG=$KUBECONFIG >> /home/vagrant/.bashrc
- name: Konfiguroi CNI-verkko
become: true
become_method: sudo
hosts: k8s-masters
tags:
- cluster-network
tasks:
- sysctl: name=net.bridge.bridge-nf-call-iptables value=1 state=present reload=yes sysctl_set=yes
- sysctl: name=net.bridge.bridge-nf-call-ip6tables value=1 state=present reload=yes sysctl_set=yes
- name: Asenna Flannel-plugin
shell: >
export KUBECONFIG=/home/vagrant/admin.conf ;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
- shell: sleep 10
- name: Alusta kubernetes workerit
become: true
become_method: sudo
hosts: k8s-workers
tags:
- cluster
tasks:
- name: kubeadm reset
shell: "kubeadm reset -f"
- name: kubeadm join
tags:
- cluster
shell: "{{ hostvars['k8s-n1'].kubeadm_join }}" # TODO
Here is the full ansible log
ansible-controller: Running ansible-playbook...
cd /vagrant && PYTHONUNBUFFERED=1 ANSIBLE_NOCOLOR=true ANSIBLE_CONFIG='ansible/ansible.cfg' ansible-playbook --limit="all" --inventory-file=ansible/hosts -v ansible/site.yml
Using /vagrant/ansible/ansible.cfg as config file
/vagrant/ansible/hosts did not meet host_list requirements, check plugin documentation if this is unexpected
/vagrant/ansible/hosts did not meet script requirements, check plugin documentation if this is unexpected
PLAY [Asenna docker ja kubernetes] *********************************************
TASK [Gathering Facts] *********************************************************
ok: [k8s-n1]
ok: [k8s-n3]
ok: [k8s-n2]
TASK [common : Testaa] *********************************************************
changed: [k8s-n3] => {"changed": true, "checksum": "6920e1826e439962050ec0ab4221719b3a045f04", "dest": "/template.test", "gid": 0, "group": "root", "md5sum": "a4f61c365318c3e23d466914fbd02687", "mode": "0644", "owner": "root", "secontext": "system_u:object_r:etc_runtime_t:s0", "size": 14, "src": "/home/vagrant/.ansible/tmp/ansible-tmp-1546760756.54-124542112178019/source", "state": "file", "uid": 0}
changed: [k8s-n2] => {"changed": true, "checksum": "6920e1826e439962050ec0ab4221719b3a045f04", "dest": "/template.test", "gid": 0, "group": "root", "md5sum": "a4f61c365318c3e23d466914fbd02687", "mode": "0644", "owner": "root", "secontext": "system_u:object_r:etc_runtime_t:s0", "size": 14, "src": "/home/vagrant/.ansible/tmp/ansible-tmp-1546760756.51-240329169302936/source", "state": "file", "uid": 0}
changed: [k8s-n1] => {"changed": true, "checksum": "6920e1826e439962050ec0ab4221719b3a045f04", "dest": "/template.test", "gid": 0, "group": "root", "md5sum": "a4f61c365318c3e23d466914fbd02687", "mode": "0644", "owner": "root", "secontext": "system_u:object_r:etc_runtime_t:s0", "size": 14, "src": "/home/vagrant/.ansible/tmp/ansible-tmp-1546760756.57-121244542660821/source", "state": "file", "uid": 0}
TASK [common : Asenna telnet] **************************************************
changed: [k8s-n2] => {"changed": true, "msg": "", "rc": 0, "results": ["Loaded plugins: fastestmirror\nLoading mirror speeds from cached hostfile\n * base: ftp.funet.fi\n * extras: ftp.funet.fi\n * updates: ftp.funet.fi\nResolving Dependencies\n--> Running transaction check\n---> Package telnet.x86_64 1:0.17-64.el7 will be installed\n--> Finished Dependency Resolution\n\nDependencies Resolved\n\n================================================================================\n Package Arch Version Repository Size\n================================================================================\nInstalling:\n telnet x86_64 1:0.17-64.el7 base 64 k\n\nTransaction Summary\n================================================================================\nInstall 1 Package\n\nTotal download size: 64 k\nInstalled size: 113 k\nDownloading packages:\nRunning transaction check\nRunning transaction test\nTransaction test succeeded\nRunning transaction\n Installing : 1:telnet-0.17-64.el7.x86_64 1/1 \n Verifying : 1:telnet-0.17-64.el7.x86_64 1/1 \n\nInstalled:\n telnet.x86_64 1:0.17-64.el7 \n\nComplete!\n"]}
changed: [k8s-n1] => {"changed": true, "msg": "", "rc": 0, "results": ["Loaded plugins: fastestmirror\nLoading mirror speeds from cached hostfile\n * base: centos.mirror.gnu.fi\n * extras: centos.mirror.gnu.fi\n * updates: centos.mirror.gnu.fi\nResolving Dependencies\n--> Running transaction check\n---> Package telnet.x86_64 1:0.17-64.el7 will be installed\n--> Finished Dependency Resolution\n\nDependencies Resolved\n\n================================================================================\n Package Arch Version Repository Size\n================================================================================\nInstalling:\n telnet x86_64 1:0.17-64.el7 base 64 k\n\nTransaction Summary\n================================================================================\nInstall 1 Package\n\nTotal download size: 64 k\nInstalled size: 113 k\nDownloading packages:\nRunning transaction check\nRunning transaction test\nTransaction test succeeded\nRunning transaction\n Installing : 1:telnet-0.17-64.el7.x86_64 1/1 \n Verifying : 1:telnet-0.17-64.el7.x86_64 1/1 \n\nInstalled:\n telnet.x86_64 1:0.17-64.el7 \n\nComplete!\n"]}
changed: [k8s-n3] => {"changed": true, "msg": "", "rc": 0, "results": ["Loaded plugins: fastestmirror\nLoading mirror speeds from cached hostfile\n * base: ftp.funet.fi\n * extras: ftp.funet.fi\n * updates: ftp.funet.fi\nResolving Dependencies\n--> Running transaction check\n---> Package telnet.x86_64 1:0.17-64.el7 will be installed\n--> Finished Dependency Resolution\n\nDependencies Resolved\n\n================================================================================\n Package Arch Version Repository Size\n================================================================================\nInstalling:\n telnet x86_64 1:0.17-64.el7 base 64 k\n\nTransaction Summary\n================================================================================\nInstall 1 Package\n\nTotal download size: 64 k\nInstalled size: 113 k\nDownloading packages:\nRunning transaction check\nRunning transaction test\nTransaction test succeeded\nRunning transaction\n Installing : 1:telnet-0.17-64.el7.x86_64 1/1 \n Verifying : 1:telnet-0.17-64.el7.x86_64 1/1 \n\nInstalled:\n telnet.x86_64 1:0.17-64.el7 \n\nComplete!\n"]}
TASK [Poista swapfile] *********************************************************
ok: [k8s-n1] => {"changed": false, "dump": "0", "fstab": "/etc/fstab", "fstype": "swap", "name": "swap", "opts": "defaults", "passno": "0"}
ok: [k8s-n2] => {"changed": false, "dump": "0", "fstab": "/etc/fstab", "fstype": "swap", "name": "swap", "opts": "defaults", "passno": "0"}
ok: [k8s-n3] => {"changed": false, "dump": "0", "fstab": "/etc/fstab", "fstype": "swap", "name": "swap", "opts": "defaults", "passno": "0"}
TASK [Disabloi swap-muisti] ****************************************************
changed: [k8s-n3] => {"changed": true, "cmd": ["swapoff", "-a"], "delta": "0:00:00.009581", "end": "2019-01-06 07:46:08.414842", "rc": 0, "start": "2019-01-06 07:46:08.405261", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [k8s-n1] => {"changed": true, "cmd": ["swapoff", "-a"], "delta": "0:00:00.119638", "end": "2019-01-06 07:46:08.484265", "rc": 0, "start": "2019-01-06 07:46:08.364627", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [k8s-n2] => {"changed": true, "cmd": ["swapoff", "-a"], "delta": "0:00:00.133924", "end": "2019-01-06 07:46:08.519646", "rc": 0, "start": "2019-01-06 07:46:08.385722", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
TASK [Konfiguroi verkkoasetukset] **********************************************
changed: [k8s-n2] => (item=ip_vs) => {"changed": true, "cmd": ["modprobe", "ip_vs"], "delta": "0:00:00.036881", "end": "2019-01-06 07:46:10.606797", "item": "ip_vs", "rc": 0, "start": "2019-01-06 07:46:10.569916", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [k8s-n3] => (item=ip_vs) => {"changed": true, "cmd": ["modprobe", "ip_vs"], "delta": "0:00:00.036141", "end": "2019-01-06 07:46:10.815043", "item": "ip_vs", "rc": 0, "start": "2019-01-06 07:46:10.778902", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [k8s-n1] => (item=ip_vs) => {"changed": true, "cmd": ["modprobe", "ip_vs"], "delta": "0:00:00.035888", "end": "2019-01-06 07:46:10.768267", "item": "ip_vs", "rc": 0, "start": "2019-01-06 07:46:10.732379", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [k8s-n2] => (item=ip_vs_rr) => {"changed": true, "cmd": ["modprobe", "ip_vs_rr"], "delta": "0:00:00.005942", "end": "2019-01-06 07:46:12.763004", "item": "ip_vs_rr", "rc": 0, "start": "2019-01-06 07:46:12.757062", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [k8s-n1] => (item=ip_vs_rr) => {"changed": true, "cmd": ["modprobe", "ip_vs_rr"], "delta": "0:00:00.006084", "end": "2019-01-06 07:46:12.896763", "item": "ip_vs_rr", "rc": 0, "start": "2019-01-06 07:46:12.890679", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [k8s-n3] => (item=ip_vs_rr) => {"changed": true, "cmd": ["modprobe", "ip_vs_rr"], "delta": "0:00:00.006325", "end": "2019-01-06 07:46:12.899750", "item": "ip_vs_rr", "rc": 0, "start": "2019-01-06 07:46:12.893425", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [k8s-n2] => (item=ip_vs_wrr) => {"changed": true, "cmd": ["modprobe", "ip_vs_wrr"], "delta": "0:00:00.006195", "end": "2019-01-06 07:46:14.795507", "item": "ip_vs_wrr", "rc": 0, "start": "2019-01-06 07:46:14.789312", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [k8s-n1] => (item=ip_vs_wrr) => {"changed": true, "cmd": ["modprobe", "ip_vs_wrr"], "delta": "0:00:00.007328", "end": "2019-01-06 07:46:14.819072", "item": "ip_vs_wrr", "rc": 0, "start": "2019-01-06 07:46:14.811744", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [k8s-n3] => (item=ip_vs_wrr) => {"changed": true, "cmd": ["modprobe", "ip_vs_wrr"], "delta": "0:00:00.007251", "end": "2019-01-06 07:46:14.863192", "item": "ip_vs_wrr", "rc": 0, "start": "2019-01-06 07:46:14.855941", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [k8s-n3] => (item=ip_vs_sh) => {"changed": true, "cmd": ["modprobe", "ip_vs_sh"], "delta": "0:00:00.007590", "end": "2019-01-06 07:46:16.815226", "item": "ip_vs_sh", "rc": 0, "start": "2019-01-06 07:46:16.807636", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [k8s-n1] => (item=ip_vs_sh) => {"changed": true, "cmd": ["modprobe", "ip_vs_sh"], "delta": "0:00:00.006380", "end": "2019-01-06 07:46:16.941470", "item": "ip_vs_sh", "rc": 0, "start": "2019-01-06 07:46:16.935090", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [k8s-n2] => (item=ip_vs_sh) => {"changed": true, "cmd": ["modprobe", "ip_vs_sh"], "delta": "0:00:00.006619", "end": "2019-01-06 07:46:16.808432", "item": "ip_vs_sh", "rc": 0, "start": "2019-01-06 07:46:16.801813", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [k8s-n3] => (item=nf_conntrack_ipv4) => {"changed": true, "cmd": ["modprobe", "nf_conntrack_ipv4"], "delta": "0:00:00.007618", "end": "2019-01-06 07:46:18.825593", "item": "nf_conntrack_ipv4", "rc": 0, "start": "2019-01-06 07:46:18.817975", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [k8s-n1] => (item=nf_conntrack_ipv4) => {"changed": true, "cmd": ["modprobe", "nf_conntrack_ipv4"], "delta": "0:00:00.008181", "end": "2019-01-06 07:46:18.910050", "item": "nf_conntrack_ipv4", "rc": 0, "start": "2019-01-06 07:46:18.901869", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [k8s-n2] => (item=nf_conntrack_ipv4) => {"changed": true, "cmd": ["modprobe", "nf_conntrack_ipv4"], "delta": "0:00:00.007427", "end": "2019-01-06 07:46:18.962850", "item": "nf_conntrack_ipv4", "rc": 0, "start": "2019-01-06 07:46:18.955423", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
TASK [Modprobe] ****************************************************************
changed: [k8s-n2] => (item=ip_vs) => {"backup": "", "changed": true, "item": "ip_vs", "msg": "line added"}
changed: [k8s-n1] => (item=ip_vs) => {"backup": "", "changed": true, "item": "ip_vs", "msg": "line added"}
changed: [k8s-n3] => (item=ip_vs) => {"backup": "", "changed": true, "item": "ip_vs", "msg": "line added"}
changed: [k8s-n2] => (item=ip_vs_rr) => {"backup": "", "changed": true, "item": "ip_vs_rr", "msg": "line added"}
changed: [k8s-n1] => (item=ip_vs_rr) => {"backup": "", "changed": true, "item": "ip_vs_rr", "msg": "line added"}
changed: [k8s-n3] => (item=ip_vs_rr) => {"backup": "", "changed": true, "item": "ip_vs_rr", "msg": "line added"}
changed: [k8s-n2] => (item=ip_vs_wrr) => {"backup": "", "changed": true, "item": "ip_vs_wrr", "msg": "line added"}
changed: [k8s-n1] => (item=ip_vs_wrr) => {"backup": "", "changed": true, "item": "ip_vs_wrr", "msg": "line added"}
changed: [k8s-n3] => (item=ip_vs_wrr) => {"backup": "", "changed": true, "item": "ip_vs_wrr", "msg": "line added"}
changed: [k8s-n2] => (item=ip_vs_sh) => {"backup": "", "changed": true, "item": "ip_vs_sh", "msg": "line added"}
changed: [k8s-n1] => (item=ip_vs_sh) => {"backup": "", "changed": true, "item": "ip_vs_sh", "msg": "line added"}
changed: [k8s-n3] => (item=ip_vs_sh) => {"backup": "", "changed": true, "item": "ip_vs_sh", "msg": "line added"}
changed: [k8s-n2] => (item=nf_conntrack_ipv4) => {"backup": "", "changed": true, "item": "nf_conntrack_ipv4", "msg": "line added"}
changed: [k8s-n1] => (item=nf_conntrack_ipv4) => {"backup": "", "changed": true, "item": "nf_conntrack_ipv4", "msg": "line added"}
changed: [k8s-n3] => (item=nf_conntrack_ipv4) => {"backup": "", "changed": true, "item": "nf_conntrack_ipv4", "msg": "line added"}
TASK [Iptables] ****************************************************************
failed: [k8s-n3] (item=net.bridge.bridge-nf-call-iptables) => {"changed": false, "item": "net.bridge.bridge-nf-call-iptables", "msg": "Failed to reload sysctl: sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory\n"}
failed: [k8s-n1] (item=net.bridge.bridge-nf-call-iptables) => {"changed": false, "item": "net.bridge.bridge-nf-call-iptables", "msg": "Failed to reload sysctl: sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory\n"}
failed: [k8s-n2] (item=net.bridge.bridge-nf-call-iptables) => {"changed": false, "item": "net.bridge.bridge-nf-call-iptables", "msg": "Failed to reload sysctl: sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory\n"}
failed: [k8s-n3] (item=net.bridge.bridge-nf-call-ip6tables) => {"changed": false, "item": "net.bridge.bridge-nf-call-ip6tables", "msg": "Failed to reload sysctl: sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory\nsysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-ip6tables: No such file or directory\n"}
failed: [k8s-n2] (item=net.bridge.bridge-nf-call-ip6tables) => {"changed": false, "item": "net.bridge.bridge-nf-call-ip6tables", "msg": "Failed to reload sysctl: sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory\nsysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-ip6tables: No such file or directory\n"}
failed: [k8s-n1] (item=net.bridge.bridge-nf-call-ip6tables) => {"changed": false, "item": "net.bridge.bridge-nf-call-ip6tables", "msg": "Failed to reload sysctl: sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory\nsysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-ip6tables: No such file or directory\n"}
to retry, use: --limit #/vagrant/ansible/site.retry
PLAY RECAP *********************************************************************
k8s-n1 : ok=7 changed=5 unreachable=0 failed=1
k8s-n2 : ok=7 changed=5 unreachable=0 failed=1
k8s-n3 : ok=7 changed=5 unreachable=0 failed=1
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
In the playbook, add the following task to load the br_netfilter module:
- name: Ensure br_netfilter is enabled.
modprobe:
name: br_netfilter
state: present
Loading br_netfilter kernel module fixed the problem. I simply appended it to the ip_modules list in playbook vars declaration. I'm using Centos 7.

Failed to start container with specified command in json

I tried multiple ways to specify docker run command but ends up with errors.
When I run kubectl get pods which returns below error in status.
rpc error: code = 2 desc = failed to start container "3329716cb47a0f795b2372dd630ca1017b0bad8bf4ab0e05490d1ac5eb28ca1b": Error response from daemon: {"message":"container 3329716cb47a0f795b2372dd630ca1017b0bad8bf4ab0e05490d1ac5eb28ca1b encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {\"ApplicationName\":\"\",\"CommandLine\":\"\\\"powershell.exe -command\\\" \\\"docker run -e VSTS_ACCOUNT=apidrop -e VSTS_TOKEN=5zcp7yf5h2dofz642eykiwpo6lj6kniu4jkmgxljipocab4vc2wa -e VSTS_POOL=apexpool --name winvs2017_vstsagent raychen320/buildagent:1.0\\\"\",\"User\":\"\",\"WorkingDirectory\":\"C:\\\\BuildAgent\",\"Environment\":{\"DOTNET_DOWNLOAD_URL\":\"https://dotnetcli.blob.core.windows.net/dotnet/preview/Binaries/1.0.4/dotnet-win-x64.1.0.4.zip\",\"DOTNET_SDK_DOWNLOAD_URL\":\"https://dotnetcli.blob.core.windows.net/dotnet/Sdk/1.0.1/dotnet-dev-win-x64.1.0.1.zip\",\"DOTNET_SDK_VERSION\":\"1.0.1\",\"DOTNET_VERSION\":\"1.0.4\",\"KUBERNETES_PORT\":\"tcp://10.0.0.1:443\",\"KUBERNETES_PORT_443_TCP\":\"tcp://10.0.0.1:443\",\"KUBERNETES_PORT_443_TCP_ADDR\":\"10.0.0.1\",\"KUBERNETES_PORT_443_TCP_PORT\":\"443\",\"KUBERNETES_PORT_443_TCP_PROTO\":\"tcp\",\"KUBERNETES_SERVICE_HOST\":\"10.0.0.1\",\"KUBERNETES_SERVICE_PORT\":\"443\",\"KUBERNETES_SERVICE_PORT_HTTPS\":\"443\",\"NUGET_XMLDOC_MODE\":\"skip\",\"chocolateyUseWindowsCompression\":\"false\"},\"EmulateConsole\":false,\"CreateStdInPipe\":true,\"CreateStdOutPipe\":true,\"CreateStdErrPipe\":true,\"ConsoleSize\":[0,0]}"} 0 26s
The Json file I use for kubectl apply command to create pod is:
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": "buildagent",
"labels": {
"name": "buildagent"
}
},
"spec": {
"containers": [
{
"name": "buildagent",
"image": "raychen320/buildagent:1.0",
"command": [
"powershell.exe -command",
"docker run -e VSTS_ACCOUNT=apitest -e VSTS_TOKEN=tgctxxx -e VSTS_POOL=testpool --name myagent raychen320/buildagent:1.0"
],
"ports": [
{
"containerPort": 80
}
]
}
],
"nodeSelector": {
"beta.kubernetes.io/os": "windows"
}
}
}
What should I set in command?
You are trying to launch an executable named powershell.exe -command which obviously does not exist. What you should try to launch is more like :
command: "powershell.exe"
args:
- "-command"
- "docker run..."
Docker can't find powershell.exe in you system PATH.
Maybe you should use full path of powershell.exe in "command"

Error running postgresql96-setup initdb with Ansible

I am trying to automate the installation of a PostgreSQL database using Ansible.
However, the following task:
- name: Initialize Postgres
command: /usr/pgsql-9.6/bin/postgresql96-setup initdb
become: true
Results in this error:
fatal: [nexus-staging.chop.edu]: FAILED! => {
"changed": true,
"cmd": "/usr/pgsql-9.6/bin/postgresql96-setup initdb",
"delta": "0:00:00.043311",
"end": "2017-02-16 23:39:12.512727",
"failed": true,
"invocation": {
"module_args": {
"_raw_params": "/usr/pgsql-9.6/bin/postgresql96-setup initdb",
"_uses_shell": true,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"warn": true
},
"module_name": "command"
},
"rc": 1,
"start": "2017-02-16 23:39:12.469416",
"stderr": "",
"stdout": "Initializing database ... failed, see /var/lib/pgsql/9.6/initdb.log",
"stdout_lines": [
"Initializing database ... failed, see /var/lib/pgsql/9.6/initdb.log"
],
"warnings": []
}
The error in /var/lib/pgsql/9.6/initdb.log is:
/usr/pgsql-9.6/bin/postgresql96-setup: line 140: runuser: command not found
What is interesting is that if I run sudo /usr/pgsql-9.6/bin/postgresql96-setup initdb on the host, it runs successfully...
Any help would be appreciated.
Try with PATH environment variable defined explicitly in the task:
- name: Initialize Postgres
command: /usr/pgsql-9.6/bin/postgresql96-setup initdb
environment:
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
become: true
Most likely the value of the path is set differently for interactive and non-interactive shell sessions.
Or locate the runuser executable and add the path before running the script:
command: PATH=/runuser/location:${PATH} /usr/pgsql-9.6/bin/postgresql96-setup initdb

Ansible playbook exiting without giving proper error message

I'm facing an issue with an Ansible playbook. Ansible is exiting without giving any proper error message. Here is my code:
- name: Installing dependencies
yum: pkg={{ item }} state=latest
with_items:
- gtk+-devel
- gtk2-devel
I wanted to install above packages in my CentOS7. I'm able to install it manually by giving the command sudo yum install gtk+-devel gtk2-devel. But Ansible is throwing the below message and exiting from execution:
TASK [server : Installing dependencies] ****************************
ok: [localhost] => (item=[u'gtk+-devel', u'gtk2-devel'])
NO MORE HOSTS LEFT *************************************************************
to retry, use: --limit #/Users/rolindroy/ansible/setup.retry
PLAY RECAP *********************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=1
Ansible version: 2.1.2.0
EDIT:
Running the playbook with the -vvv option yields this error (but I'm able to install it manually):
failed: [localhost] (item=[u'gtk+-devel', u'gtk2-devel']) => {"changed": false, "failed": true, "invocation": {"module_args": {"conf_file": null, "disable_gpg_check": false, "disablerepo": null, "enablerepo": null, "exclude": null, "install_repoquery": true, "list": null, "name": ["gtk+-devel", "gtk2-devel"], "state": "latest", "update_cache": false, "validate_certs": true}, "module_name": "yum"}, "item": ["gtk+-devel", "gtk2-devel"], "msg": "No Package matching 'gtk+-devel' found available, installed or updated", "rc": 0, "results": []}