{{ hostvars['test.example.com']['ansible_distribution'] }}
Since I am looping over groups['webservers'], I have the name of the web server in {{ item }}. How to I inject that variable name in the expression?
The following do not work ( substituting lineinfile with shell to illustrating the variable problem ) :
- name: FW rule - accept input 3306 from web server to DB server
shell: /bin/true {{ hostvars.item.ansible_eth0["ipv4"]["address"] }} {{ hostvars.[{{ 'item' }}].ansible_eth0["ipv4"]["address"] }}
with_items: groups['webservers']
notify:
- Restart iptables on DB server
tags: fwrules
Btw, when using Rolles ( http://docs.ansible.com/playbooks_roles.html#roles ), in which file may I specify Serial ?
Neither in tasks/main.yml, handlers/main.yml or vars/main.yml seems to work....
Best regards,
Vidar
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Serial needs to be set per play.But you can have multiple plays per file, so start a new play for the section that you want to run in serial mode.
Roles are just abstractions around tasks.Plays map roles to hosts.You do it in the play, and the play *has* the role assignments.You can put more than one play in a playbook.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/06f019d4-f8f7-47f9-97a5-e68c3e78959d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/rBcWzXjt-Xc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgzPa3qz-nNAhjLdBLHivhWhpB6HrUJFPvyXd6hAKu%3DfOA%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20140721101104.GE14256%40subiron.org.
---
# This playbook upgrades a the social cluster to DSE 4.0.4
# Apply common configuration to all hosts
- hosts: all
gather_facts: no
tasks:
- include: maintest.yaml
- include: restart.yaml okay_to_run={{ out.rc }}
- name: group my play
group_by: key=my_ad_hoc_on_the_fly_group
- name: main task1
command: "echo main.yaml task 1"
- name: main task2
command: "echo main.yaml task 2"
# say this is the tasks that is supposed to "notify" restart
- name: main task1
command: "echo main.yaml task 3"
register: out
---
- hosts: my_ad_hoc_on_the_fly_group
serial: 1
tasks:
- name: restart host
command: "echo I would restart 1"
when: ok_to_run.rc == 0
import fcntl
class ActionModule(object):
def __init__(self, runner):
self.runner = runner
def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **kwargs):
lock_file = open('/tmp/serialize.lock', 'w')
fcntl.flock(lock_file.fileno(), fcntl.LOCK_EX)
module_name, module_args = module_args.split(' ', 1)
return self.runner._execute_module(conn, tmp, module_name, module_args, inject=inject, complex_args=complex_args, **kwargs)
Dropping this in action_plugins/synchronize.py and touching library/synchronize.py -- you can invoke this in your playbook:
- name: restart foo
serialize: command supervisorctl -c /etc/supervisord.conf signal HUP foo
m
FAILED! => {"failed": true, "reason": "ERROR! this task 'serialize' has extra params, which is only allowed in the following modules: command, shell, script, include, include_vars, add_host, group_by, set_fact, raw
, meta\n\nThe error appears to have been in '/home/ansible/slave/workspace/pr_test_prov2/ansible/roles/bootstrap_nodes/tasks/cobbler_netboot.yaml': line 4, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.
\n\nThe offending line appears to be:\n\n\n- name: set cobbler netboot flag\n ^ here\n"}
- name: set cobbler netboot flag
serialize: command "docker exec -it cobbler cobbler system edit --netboot-enabled=true --name={{inventory_hostname}}-pxe"