diff --git a/README.md b/README.md index aab1663..135ebf8 100644 --- a/README.md +++ b/README.md @@ -12,20 +12,26 @@ The playbook Only two modules are needed for this example. The [nxos_facts module][1] and the [template module][5] ``` -- hosts: cisco - connection: local +--- +- name: build NXOS inventory report + hosts: nxos + connection: network_cli gather_facts: False + vars: desired_version: "7.0(3)I7(1)" + file_path: /var/www/html/generated_report.html + tasks: - name: gathering nxos facts nxos_facts: provider: "{{login_info}}" + register: all_facts - name: create HTML report template: src: report.j2 - dest: /var/www/html/generated_report.html + dest: "{{ file_path }}" delegate_to: localhost run_once: true ``` @@ -120,7 +126,7 @@ Red HatĀ® AnsibleĀ® Automation consists of three products: [1]: http://docs.ansible.com/ansible/latest/nxos_facts_module.html [2]: http://docs.ansible.com/ansible/latest/list_of_network_modules.html -[3]: htmlreport.png +[3]: images/htmlreport.png [4]: http://docs.ansible.com/ansible/latest/ios_facts_module.html [5]: http://docs.ansible.com/ansible/latest/template_module.html [6]: images/rh-ansible-automation.png diff --git a/ansible.cfg b/ansible.cfg index ac83a52..09616d2 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -3,5 +3,6 @@ deprecation_warnings=False host_key_checking = False inventory = hosts gathering = explicit +retry_files_enabled = False # Do not create them [paramiko_connection] host_key_auto_add = True diff --git a/hosts b/hosts index f7a83e0..8ce93d6 100644 --- a/hosts +++ b/hosts @@ -17,7 +17,7 @@ localhost [mac] 192.168.2.1 -[cisco] +[nxos] n9k ansible_host=192.168.2.3 n9k2 ansible_host=192.168.2.3 n9k3 ansible_host=192.168.2.3 @@ -28,5 +28,5 @@ n9k6 ansible_host=192.168.2.3 [ios:vars] ansible_network_os=ios -[cisco:vars] +[nxos:vars] ansible_network_os=nxos diff --git a/htmlreport.png b/images/htmlreport.png similarity index 100% rename from htmlreport.png rename to images/htmlreport.png diff --git a/inventory-ios.yml b/inventory-ios.yml index bff0207..982c2a2 100644 --- a/inventory-ios.yml +++ b/inventory-ios.yml @@ -1,22 +1,22 @@ --- - - name: build IOS XE inventory + - name: build IOS inventory report hosts: ios connection: network_cli gather_facts: False vars: desired_ios_version: "16.06.01" + file_path: /var/www/html/inventory_report_ios.html tasks: - - name: gathering IOS XE facts + - name: gathering IOS facts ios_facts: register: all_facts - name: create HTML report template: src: report-ios.j2 - dest: /var/www/html/inventory_report_ios.html + dest: "{{ file_path }}" delegate_to: localhost run_once: true -# provider: "{{login_info}}" diff --git a/inventory.yml b/inventory.yml index cecd38e..517f457 100644 --- a/inventory.yml +++ b/inventory.yml @@ -1,21 +1,22 @@ --- -- hosts: cisco +- name: build NXOS inventory report + hosts: nxos connection: network_cli gather_facts: False + vars: desired_version: "7.0(3)I7(1)" + file_path: /var/www/html/generated_report.html + tasks: - name: gathering nxos facts nxos_facts: provider: "{{login_info}}" register: all_facts -# - debug: -# var: all_facts - - name: create HTML report template: src: report.j2 - dest: /var/www/html/generated_report.html + dest: "{{ file_path }}" delegate_to: localhost run_once: true