The loop variable 'item' is already in use. You should set the `loop_var` value in the `loop_control` option for the task to something else to avoid variable collisions and unexpected behavior.

626 views
Skip to first unread message

Moncy Varghese

unread,
Feb 5, 2018, 9:58:42 AM2/5/18
to Ansible Project
Dear All,


I  am having issues running the  final step  for ansible , openstack-ansible setup-openstack.yml .It reports the below error
/opt/openstack-ansible/playbooks# screen
Monday 05 February 2018  16:27:19 +0300 (0:00:00.106)       0:00:07.180 *******
 [WARNING]: The loop variable 'item' is already in use. You should set the `loop_var` value in the `loop_control` option for the task to something else to avoid variable collisions and
unexpected behavior.

ok: [infra1_keystone_container-465fb3c6 -> 10.7.8.5] => (item=infra1)
failed: [infra1_keystone_container-465fb3c6 -> 10.7.8.4] (item=infra2) => {"failed": true, "item": "infra2", "module_stderr": "Shared connection to 10.7.8.4 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_jFdbF1/ansible_module_haproxy.py\", line 350, in <module>\r\n    main()\r\n  File \"/tmp/ansible_jFdbF1/ansible_module_haproxy.py\", line 345, in main\r\n    ansible_haproxy.act()\r\n  File \"/tmp/ansible_jFdbF1/ansible_module_haproxy.py\", line 299, in act\r\n    state_before = self.get_state_for(self.backend, self.host)\r\n  File \"/tmp/ansible_jFdbF1/ansible_module_haproxy.py\", line 245, in get_state_for\r\n    data = self.execute('show stat', 200, False).lstrip('# ')\r\n  File \"/tmp/ansible_jFdbF1/ansible_module_haproxy.py\", line 181, in execute\r\n    self.client.connect(self.socket)\r\n  File \"/usr/lib/python2.7/socket.py\", line 228, in meth\r\n    return getattr(self._sock,name)(*args)\r\nsocket.error: [Errno 111] Connection refused\r\n", "msg": "MODULE FAILURE"}
failed: [infra1_keystone_container-465fb3c6 -> 10.7.8.3] (item=infra3) => {"failed": true, "item": "infra3", "module_stderr": "Shared connection to 10.7.8.3 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_nc1nm4/ansible_module_haproxy.py\", line 350, in <module>\r\n    main()\r\n  File \"/tmp/ansible_nc1nm4/ansible_module_haproxy.py\", line 345, in main\r\n    ansible_haproxy.act()\r\n  File \"/tmp/ansible_nc1nm4/ansible_module_haproxy.py\", line 299, in act\r\n    state_before = self.get_state_for(self.backend, self.host)\r\n  File \"/tmp/ansible_nc1nm4/ansible_module_haproxy.py\", line 245, in get_state_for\r\n    data = self.execute('show stat', 200, False).lstrip('# ')\r\n  File \"/tmp/ansible_nc1nm4/ansible_module_haproxy.py\", line 181, in execute\r\n    self.client.connect(self.socket)\r\n  File \"/usr/lib/python2.7/socket.py\", line 228, in meth\r\n    return getattr(self._sock,name)(*args)\r\nsocket.error: [Errno 111] Connection refused\r\n", "msg": "MODULE FAILURE"}

My external and Internal LIb Ip are the same .

My second question is around haproxy ho do we ensure that all the components of infrastructure are up and running. For example isnt there single commmand to list all the services that are up and running. How do we troubleshoot haproxy  , how do we shut it down properly and start it up properly . Kindly please guide me as this is my first experience with ansible . Much appreciated

regards
Moncy


ZillaYT

unread,
Feb 5, 2018, 11:13:35 AM2/5/18
to Ansible Project
Where's your code?

ZillaYT

unread,
Feb 5, 2018, 11:49:57 AM2/5/18
to Ansible Project
Regarding your second question about HAproxy and Ansible, well Ansible is NOT magic. Ansible does NOT do anything you wouldn't/couldn't manually, or in any other scripting language, do otherwise. For example, if I want to install services via package manger I may do this

Shell script
PKGS=("pkg1", "pkg2", pkg3")
for PKG in ${PKGS[@]}; do
  yum install $PKG -y
done

Ansible
vars:
  PKGS
:
 
- pkg1
 
- pkg2
 
- pkg3
  tasks
:
 
- name: Install above packages
   
package:
      name
: "{{ item }}"
      state
: present
    with_items
: "{{ PKGS }}"

You can discern how the two scripts are similar.

However the shell script will ONLY work in a CentOS/RHEL environment, which use the yum package manger. It won't work in Ubuntu since it uses apt. Correct?

However, the Ansible code will work anywhere, since under the covers, Ansible will "know" the underlying OS it's running on, and use the appropriate package manager.

Hope that helps.

On Monday, February 5, 2018 at 9:58:42 AM UTC-5, Moncy Varghese wrote:
Reply all
Reply to author
Forward
0 new messages