It seems as the playbook is too long for one post: Here comes the second 
part of playbook:

(..)
- hosts: SLES
  gather_facts: False
  vars:
    fragment_file: "{{ ansible_distribution }}.frag"

  tasks:
   - name: Template file {{ path_to_fragments }}/{{ fragment_file }}
     local_action: template 
src=std-templates/std-playbook-make-inventory-by-os.j2 dest={{ 
path_to_fragments }}/{{ fragment_file }} owner=admin2 group=admin2 mode=0400
     run_once: true
     changed_when: False

   - name: Lineinfile header to file {{ path_to_fragments }}/{{ 
fragment_file }}
     local_action: lineinfile dest={{ path_to_fragments }}/{{ fragment_file 
}} insertbefore=BOF line="[{{ ansible_distribution }}]"
     run_once: true
     changed_when: False



- hosts: SLES-12
  gather_facts: False
  vars:
    fragment_file: "{{ ansible_distribution }}-{{ 
ansible_distribution_major_version }}.frag"

  tasks:
   - name: Template file {{ path_to_fragments }}/{{ fragment_file }}
     local_action: template 
src=std-templates/std-playbook-make-inventory-by-os.j2 dest={{ 
path_to_fragments }}/{{ fragment_file }} owner=admin2 group=admin2 mode=0400
     run_once: true
     changed_when: False

   - name: Lineinfile header to file {{ path_to_fragments }}/{{ 
fragment_file }}
     local_action: lineinfile dest={{ path_to_fragments }}/{{ fragment_file 
}} insertbefore=BOF line="[{{ ansible_distribution }}-{{ 
ansible_distribution_major_version }}]"
     run_once: true
     changed_when: False



- hosts: SLES-12-0
  gather_facts: False
  vars:
    fragment_file: "{{ ansible_distribution }}-{{ 
ansible_distribution_major_version }}-{{ ansible_distribution_release 
}}.frag"

  tasks:
   - name: Template file {{ path_to_fragments }}/{{ fragment_file }}
     local_action: template 
src=std-templates/std-playbook-make-inventory-by-os.j2 dest={{ 
path_to_fragments }}/{{ fragment_file }} owner=admin2 group=admin2 mode=0400
     run_once: true
     changed_when: False

   - name: Lineinfile header to file {{ path_to_fragments }}/{{ 
fragment_file }}
     local_action: lineinfile dest={{ path_to_fragments }}/{{ fragment_file 
}} insertbefore=BOF line="[{{ ansible_distribution }}-{{ 
ansible_distribution_major_version }}-{{ansible_distribution_release }}]"
     run_once: true
     changed_when: False



- hosts: SLES-11
  gather_facts: False
  vars:
    fragment_file: "{{ ansible_distribution }}-{{ 
ansible_distribution_major_version }}.frag"

  tasks:
   - name: Template file {{ path_to_fragments }}/{{ fragment_file }}
     local_action: template 
src=std-templates/std-playbook-make-inventory-by-os.j2 dest={{ 
path_to_fragments }}/{{ fragment_file }} owner=admin2 group=admin2 mode=0400
     run_once: true
     changed_when: False

   - name: Lineinfile header to file {{ path_to_fragments }}/{{ 
fragment_file }}
     local_action: lineinfile dest={{ path_to_fragments }}/{{ fragment_file 
}} insertbefore=BOF line="[{{ ansible_distribution }}-{{ 
ansible_distribution_major_version }}]"
     run_once: true
     changed_when: False



- hosts: SLES-11-4
  gather_facts: False
  vars:  
    fragment_file: "{{ ansible_distribution }}-{{ 
ansible_distribution_major_version }}-{{ ansible_distribution_release 
}}.frag"

  tasks:
   - name: Template file {{ path_to_fragments }}/{{ fragment_file }} 
     local_action: template 
src=std-templates/std-playbook-make-inventory-by-os.j2 dest={{ 
path_to_fragments }}/{{ fragment_file }} owner=admin2 group=admin2 mode=0400
     run_once: true
     changed_when: False

   - name: Lineinfile header to file {{ path_to_fragments }}/{{ 
fragment_file }}  
     local_action: lineinfile dest={{ path_to_fragments }}/{{ fragment_file 
}} insertbefore=BOF line="[{{ ansible_distribution }}-{{ 
ansible_distribution_major_version }}-{{ ansible_distribution_release }}]"
     run_once: true    
     changed_when: False



- hosts: Solaris
  gather_facts: False
  vars:
    fragment_file: "{{ ansible_distribution }}.frag"

  tasks:
   - name: Template file {{ path_to_fragments }}/{{ fragment_file }}
     local_action: template 
src=std-templates/std-playbook-make-inventory-by-os.j2 dest={{ 
path_to_fragments }}/{{ fragment_file }} owner=admin2 group=admin2 mode=0400
     run_once: true
     changed_when: False

   - name: Lineinfile header to file {{ path_to_fragments }}/{{ 
fragment_file }}
     local_action: lineinfile dest={{ path_to_fragments }}/{{ fragment_file 
}} insertbefore=BOF line="[{{ ansible_distribution }}]"
     run_once: true
     changed_when: False



- hosts: Solaris-11.2
  gather_facts: False
  vars:
    fragment_file: "{{ ansible_distribution }}-{{ 
ansible_distribution_version }}.frag"

  tasks:
   - name: Template file {{ path_to_fragments }}/{{ fragment_file }}
     local_action: template 
src=std-templates/std-playbook-make-inventory-by-os.j2 dest={{ 
path_to_fragments }}/{{ fragment_file }} owner=admin2 group=admin2 mode=0400
     run_once: true
     changed_when: False

   - name: Lineinfile header to file {{ path_to_fragments }}/{{ 
fragment_file }}
     local_action: lineinfile dest={{ path_to_fragments }}/{{ fragment_file 
}} insertbefore=BOF line="[{{ ansible_distribution }}-{{ 
ansible_distribution_version }}]"
     run_once: true
     changed_when: False



- hosts: Solaris-10
  gather_facts: False
  vars:
    fragment_file: "{{ ansible_distribution }}-{{ 
ansible_distribution_version }}.frag"

  tasks:
   - name: Template file {{ path_to_fragments }}/{{ fragment_file }}
     local_action: template 
src=std-templates/std-playbook-make-inventory-by-os.j2 dest={{ 
path_to_fragments }}/{{ fragment_file }} owner=admin2 group=admin2 mode=0400
     run_once: true
     changed_when: False

   - name: Lineinfile header to file {{ path_to_fragments }}/{{ 
fragment_file }}
     local_action: lineinfile dest={{ path_to_fragments }}/{{ fragment_file 
}} insertbefore=BOF line="[{{ ansible_distribution }}-{{ 
ansible_distribution_version }}]"
     run_once: true
     changed_when: False



- hosts: all[0]
  gather_facts: False

  tasks:
  - name: Assemble fragments to file {{ file_inventory }}
    local_action: assemble src={{ path_to_fragments }} dest={{ 
file_inventory }} owner=admin2 group=admin2 mode=0644
    changed_when: False

  - name: Add header block to file {{ file_inventory }} 
    local_action:
      module: blockinfile
      dest: "{{ file_inventory }}"
      state: present
      block: |
       #
       #
       # This file is generated using a cron job and 
playbooks/std-playbook-make-inventory-by-os.yml
      
       #
      insertbefore: BOF

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f0152406-f1a9-4246-8f9e-b4c9d6ed9517%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to