Skip to content

Commit

Permalink
Merge pull request #2 from jabl/template
Browse files Browse the repository at this point in the history
Create pdsh machines file from template
  • Loading branch information
martbhell committed May 19, 2016
2 parents b1a3b8a + b662530 commit daaae95
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
3 changes: 0 additions & 3 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ pdsh_el6_packages:
- pdsh-mod-netgroup
- pdsh-rcmd-ssh

# The group in the hosts file we populate

# The group in the hosts file we populate
pdsh_group: "{{ groups['compute'] }}"
pdsh_name_var: pxe_name
pdsh_local_file: "files/machines"
16 changes: 2 additions & 14 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,8 @@
- include: redhat.yml
when: ansible_os_family == "RedHat"

- name: populate machines file locally
lineinfile:
dest={{ pdsh_local_file }}
regexp='^{{ hostvars[item].inventory_hostname }}$'
line="{{ hostvars[item].inventory_hostname }}"
state=present
create=yes
with_items: "{{ pdsh_group }}"
delegate_to: localhost
become: no
register: reg_pdsh_machines

- name: copy in /etc/machines
copy: src={{ pdsh_local_file }} dest=/etc/machines mode=0644
- name: populate machines file
template: src='pdsh_machines.j2' dest='/etc/machines' mode='0644' owner=root group=root

# TODO: Make dsh groups
# - debug: var=groups
Expand Down
3 changes: 3 additions & 0 deletions templates/pdsh_machines.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% for item in pdsh_group %}
{{ hostvars[item].inventory_hostname }}
{% endfor %}

0 comments on commit daaae95

Please sign in to comment.