CORD-391 - cleaned up ansible to pass cleanly through ansible-lint

Change-Id: I90284704255edc19abbdb239852c520a4bf48df4
diff --git a/ansible/roles/common/tasks/main.yml b/ansible/roles/common/tasks/main.yml
index 0ad01a7..b7d5eb2 100644
--- a/ansible/roles/common/tasks/main.yml
+++ b/ansible/roles/common/tasks/main.yml
@@ -9,13 +9,13 @@
     dest: /etc/hosts
     regexp: "^{{ item.host_ip }}"
     line: "{{ item.host_ip }} {{ item.host_name }}"
-  with_items: hosts
+  with_items: "{{ hosts }}"
   tags: [common]
 
 - name: Latest apt packages
   apt:
     name: "{{ item }}"
-  with_items: use_latest_for
+  with_items: "{{ use_latest_for }}"
   tags: [common]
 
 - name: Services are not running
@@ -23,7 +23,7 @@
     name: "{{ item }}"
     state: stopped
   ignore_errors: yes
-  with_items: obsolete_services
+  with_items: "{{ obsolete_services }}"
   tags: [common]
 
 - name: Ensure SSH Directory
diff --git a/ansible/roles/docker/tasks/centos.yml b/ansible/roles/docker/tasks/centos.yml
index a8910d4..cdfd0b4 100644
--- a/ansible/roles/docker/tasks/centos.yml
+++ b/ansible/roles/docker/tasks/centos.yml
@@ -2,7 +2,7 @@
   copy:
     src: "{{ item.src }}"
     dest: "{{ item.dest }}"
-  with_items: centos_files
+  with_items: "{{ centos_files }}"
   tags: [docker]
 
 - name: CentOS package is installed
@@ -13,6 +13,7 @@
 
 - name: CentOS Daemon is reloaded
   command: systemctl daemon-reload
+  changed_when: true
   tags: [docker]
 
 - name: CentOS service is running
diff --git a/ansible/roles/docker/tasks/debian.yml b/ansible/roles/docker/tasks/debian.yml
index aa10934..55178b1 100644
--- a/ansible/roles/docker/tasks/debian.yml
+++ b/ansible/roles/docker/tasks/debian.yml
@@ -7,8 +7,8 @@
 
 - name: Debian Docker is present
   apt:
-    name: docker-engine
-    state: latest
+    name: docker-engine=1.12*
+    state: present
     force: yes
   tags: [docker]
 
@@ -58,4 +58,4 @@
     volumes:
       - /var/run/docker.sock:/var/run/docker.sock
   when: not skip_ui is defined
-  tags: [docker]
\ No newline at end of file
+  tags: [docker]
diff --git a/ansible/roles/java8-oracle/tasks/main.yml b/ansible/roles/java8-oracle/tasks/main.yml
index c38dd54..9bdc946 100644
--- a/ansible/roles/java8-oracle/tasks/main.yml
+++ b/ansible/roles/java8-oracle/tasks/main.yml
@@ -1,20 +1,20 @@
 ---
 - name: Install add-apt-repository
-  sudo: yes
-  apt: name=software-properties-common state=latest update_cache=yes
+  become: yes
+  apt: name=software-properties-common=0.92* state=present update_cache=yes
 
 - name: Add Oracle Java repository
-  sudo: yes
+  become: yes
   apt_repository: repo='ppa:webupd8team/java' update_cache=yes
 
 - name: Accept Java 8 license
-  sudo: yes
+  become: yes
   debconf: name='oracle-java8-installer' question='shared/accepted-oracle-license-v1-1' value='true' vtype='select'
 
 - name: Install Oracle Java 8
-  sudo: yes
-  apt: name={{item}} state=latest
+  become: yes
+  apt: name={{item}} state=present
   with_items:
-  - oracle-java8-installer
-  - ca-certificates
-  - oracle-java8-set-default
+  - oracle-java8-installer=8*
+  - ca-certificates=14.04*
+  - oracle-java8-set-default=8*
diff --git a/config/develop.yml b/config/develop.yml
index a42e9e8..b96bf12 100644
--- a/config/develop.yml
+++ b/config/develop.yml
@@ -13,7 +13,7 @@
 
   # Specifies tasks within the head node provisioning not to execute, including:
   #
-  # switch_support -   don't download the switch ONL images as there are no 
+  # switch_support -   don't download the switch ONL images as there are no
   #                    switches in this configuration
   # interface_config - don't update the network configuration of the headnode
   #                    as it is configured by vagrant to the proper settings
diff --git a/config/pod5.yml b/config/pod5.yml
index c54f9c4..b001bdd 100644
--- a/config/pod5.yml
+++ b/config/pod5.yml
@@ -14,12 +14,12 @@
   #
   # management_ip - the IP address and mask bits to be used to configure the network
   #                 interface connecting the head node to the POD internal
-  #                 management network. The head node will deliver DHCP addresses to 
+  #                 management network. The head node will deliver DHCP addresses to
   #                 the other compute nodes over this interface
   #
   # external_ip   - the IP address and mask bits to be used to configure the network
-  #                 interface connecting the head node (and the POD) to the 
-  #                 Internet. All traffic in the POD to external hosts will be 
+  #                 interface connecting the head node (and the POD) to the
+  #                 Internet. All traffic in the POD to external hosts will be
   #                 NAT-ed through this interface
   fabric_ip: '10.6.1.1/24'
   management_ip: '10.6.0.1/24'
diff --git a/roles/ansible/tasks/main.yml b/roles/ansible/tasks/main.yml
index f97ecf8..19e285d 100644
--- a/roles/ansible/tasks/main.yml
+++ b/roles/ansible/tasks/main.yml
@@ -6,5 +6,5 @@
 - name: Ensure Ansible
   become: yes
   apt:
-    name=ansible
-    state=latest
+    name=ansible=2.1.1.*
+    state=present
diff --git a/roles/compute-node/tasks/i40e_driver.yml b/roles/compute-node/tasks/i40e_driver.yml
index 69c14cd..78bd3ef 100644
--- a/roles/compute-node/tasks/i40e_driver.yml
+++ b/roles/compute-node/tasks/i40e_driver.yml
@@ -21,6 +21,7 @@
   command: make install
   args:
     chdir: i40e-1.4.25/src
+  changed_when: true
 
 - name: Load i40e Driver
   become: yes
diff --git a/roles/compute-node/tasks/main.yml b/roles/compute-node/tasks/main.yml
index f74ab55..ebbb1be 100644
--- a/roles/compute-node/tasks/main.yml
+++ b/roles/compute-node/tasks/main.yml
@@ -9,17 +9,17 @@
 
 - name: Applications
   become: yes
-  apt: name={{ item }} state=latest force=yes
+  apt: name={{ item }} state=present force=yes
   with_items:
-    - build-essential
-    - git
-    - python-pip
-    - ifenslave-2.6
-    - bridge-utils
-    - ethtool
-    - minicom
-    - curl
-    - jq
+    - build-essential=11.6*
+    - git=1:1.9.*
+    - python-pip=1.5.4*
+    - ifenslave-2.6=2.4*
+    - bridge-utils=1.5-*
+    - ethtool=1:3.13*
+    - minicom=2.7*
+    - curl=7.35.*
+    - jq=1.4*
 
 - name: Ensure Docker Insecure Repository
   become: yes
@@ -139,13 +139,13 @@
     - interface_config
 
 - name: Update mlx4 Driver
-  include: tasks/mlx4_driver.yml
+  include: mlx4_driver.yml
   when: mlx_nic_present.stdout != "0" and mlx4_version.stdout != '3.1-1.0.4'
   tags:
     - interface_config
 
 - name: Update i40e Driver
-  include: tasks/i40e_driver.yml
+  include: i40e_driver.yml
   when: intel_nic_present.stdout != "0" and i40e_version.stdout != '1.4.25'
   tags:
     - interface_config
diff --git a/roles/compute-node/tasks/mlx4_driver.yml b/roles/compute-node/tasks/mlx4_driver.yml
index 06219d2..a9b76f0 100644
--- a/roles/compute-node/tasks/mlx4_driver.yml
+++ b/roles/compute-node/tasks/mlx4_driver.yml
@@ -17,6 +17,7 @@
 - name: Install mlx4 driver
   become: yes
   command: /tmp/mlnx-en-3.1-1.0.4/install.sh --batch
+  changed_when: true
 
 - name: Remove Build Directory
   become: yes
diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml
index cd609fa..644bd80 100644
--- a/roles/docker/tasks/main.yml
+++ b/roles/docker/tasks/main.yml
@@ -1,9 +1,9 @@
 - name: Apt Information
   become: yes
-  apt: name={{ item }} state=latest force=yes
+  apt: name={{ item }} state=present force=yes
   with_items:
-    - apt-transport-https
-    - ca-certificates
+    - apt-transport-https=1.0*
+    - ca-certificates=20160104*
 
 - name: Docker Apt Key
   become: yes
@@ -21,8 +21,8 @@
 - name: Docker Engine
   become: yes
   apt:
-    name: docker-engine
-    state: latest
+    name: docker-engine=1.12*
+    state: present
     force: yes
 
 - name: Docker Exposed via TCP
diff --git a/roles/fabric-switch/tasks/main.yml b/roles/fabric-switch/tasks/main.yml
index 41251e7..e9e2873 100644
--- a/roles/fabric-switch/tasks/main.yml
+++ b/roles/fabric-switch/tasks/main.yml
@@ -15,7 +15,7 @@
   changed_when: false
 
 - name: Openflow Agent Version
-  shell: ofdpa --version
+  command: ofdpa --version
   register: ofdpa_version
   changed_when: false
   when: ofdpa_exists.stdout != "0"
diff --git a/roles/fabric-switch/tasks/ofdpa.yml b/roles/fabric-switch/tasks/ofdpa.yml
index 21af257..c1c0b37 100644
--- a/roles/fabric-switch/tasks/ofdpa.yml
+++ b/roles/fabric-switch/tasks/ofdpa.yml
@@ -39,7 +39,9 @@
 
 - name: Mark Persist Openflow Agent
   command: persist /etc/accton/ofdpa.conf
+  changed_when: true
 
 - name: Persist Openflow Agent
   command: savepersist
   failed_when: false
+  changed_when: true
diff --git a/roles/head-node/files/compute-node.yml b/roles/head-node/files/compute-node.yml
index ba2bd24..b8eb496 100644
--- a/roles/head-node/files/compute-node.yml
+++ b/roles/head-node/files/compute-node.yml
@@ -3,7 +3,8 @@
   hosts: all
   remote_user: ubuntu
   tasks:
-  - include_vars: vars/compute-node.yml
+  - name: Include variables
+    include_vars: vars/compute-node.yml
 
 - name: Configure compute hosts to use DNS server
   hosts: all
diff --git a/roles/head-node/files/connect-switch.yml b/roles/head-node/files/connect-switch.yml
index da4edb0..5fdb996 100644
--- a/roles/head-node/files/connect-switch.yml
+++ b/roles/head-node/files/connect-switch.yml
@@ -5,6 +5,7 @@
     - name: Lookup DHCP harvest
       shell: cat /etc/bind/maas/dhcp_harvest.inc | grep -i " cc:37:ab\| 70:72;cf" | awk '{print $1}'
       register: switches
+      changed_when: false
     - name: Add hosts into inventory
       add_host: name={{item}} group=fabric
       with_items: "{{switches.stdout_lines}}"
@@ -24,9 +25,11 @@
 
     - name: Purge hardware tables
       command: /root/purge
+      changed_when: true
 
     - name: Start indigo agent
       command: /root/connect -bg
+      changed_when: true
 
     - name: Verify indigo agent has been started
       command: ps aux
diff --git a/roles/maas/tasks/download.yml b/roles/maas/tasks/download.yml
index d5b2243..1fc73c7 100644
--- a/roles/maas/tasks/download.yml
+++ b/roles/maas/tasks/download.yml
@@ -7,8 +7,10 @@
 - name: Get Remote Size
   shell: curl -sSL -I "{{ item.url }}" | grep Content-Length | tail -1 | cut "-d " -f2
   register: remote_size
+  changed_when: false
   tags:
     - switch_support
+    - skip_ansible_lint
 
 - name: Check Local File
   stat:
@@ -23,6 +25,7 @@
   when: local_size.stat.exists == false or remote_size.stdout|int != local_size.stat.size
   tags:
     - switch_support
+    - skip_ansible_lint
 
 - name: Switch Boot Resources Permissions
   become: yes
diff --git a/roles/maas/tasks/main.yml b/roles/maas/tasks/main.yml
index 7b9089e..be2600f 100644
--- a/roles/maas/tasks/main.yml
+++ b/roles/maas/tasks/main.yml
@@ -6,26 +6,27 @@
   failed_when: false
   changed_when: false
 
-- fail: msg="The head node must have a network bridge named 'mgmtbr' to continue the deployment. Please see docuemataiton at 'http://github.com/opencord/cord`."
+- name: Verify Management Bridge
+  fail: msg="The head node must have a network bridge named 'mgmtbr' to continue the deployment. Please see docuemataiton at 'http://github.com/opencord/cord`."
   when: have_mgmtbr.rc != 0
 
 - name: Install Prerequisites
   become: yes
-  apt: name={{ item }} state=latest force=true
+  apt: name={{ item }} state=present force=true
   with_items:
-    - git
-    - bridge-utils
-    - curl
-    - python-pycurl
-    - python-pip
-    - ethtool
-    - jq
+    - git=1:1.9.*
+    - bridge-utils=1.5-*
+    - curl=7.35.*
+    - python-pycurl=7.19.*
+    - python-pip=1.5.4*
+    - ethtool=1:3.13*
+    - jq=1.4*
 
 - name: Install Python Prerequisites
   become: yes
-  pip: name={{ item }} state=latest
+  pip: name={{ item.name }} version={{ item.version }} state=present
   with_items:
-    - docker-py
+    - { name: "docker-py", version: "1.9.*" }
 
 - name: Stop Containers
   become: yes
@@ -304,6 +305,7 @@
 - name: Ensure Boot Resource Import Started
   become: yes
   shell: maas login cord http://localhost/MAAS/api/1.0/ "{{apikey.stdout}}" && maas cord boot-resources import && maas logout cord
+  changed_when: true
 
 - name: Ensure VirtualBox Power Management
   include: virtualbox.yml
@@ -320,6 +322,7 @@
 - name: Ensure SSH keys for Ansible
   become: yes
   command: cp {{ ansible_env['PWD'] }}/.ssh/id_rsa /etc/maas/ansible/id_rsa
+  changed_when: true
 
 - name: Ensure SSH Key Permissions
   become: yes
@@ -371,6 +374,7 @@
   with_items:
     - automation-compose.yml
     - harvest-compose.yml
+  changed_when: true
 
 - name: Wait For Image Download
   shell: maas login cord http://localhost/MAAS/api/1.0/ "{{apikey.stdout}}" > /dev/null 2>&1 && maas cord boot-resources read | jq 'map(select(.type != "Synced"))' && maas  logout  cord > /dev/null 2>&1
@@ -379,3 +383,4 @@
   retries: 5
   delay: 60
   failed_when: images_synced.stdout != "[]"
+  changed_when: false
diff --git a/roles/maas/tasks/virtualbox.yml b/roles/maas/tasks/virtualbox.yml
index 88dcba7..6d3c03f 100644
--- a/roles/maas/tasks/virtualbox.yml
+++ b/roles/maas/tasks/virtualbox.yml
@@ -1,9 +1,9 @@
 - name: VirtualBox Power Support
   become: yes
-  apt: name={{ item }} state=latest
+  apt: name={{ item }} state=present
   with_items:
-    - amtterm
-    - wsmancli
+    - amtterm=1.4*
+    - wsmancli=2.3.*
 
 - name: VirtualBox Power Script
   become: yes
diff --git a/roles/onos-fabric/tasks/main.yml b/roles/onos-fabric/tasks/main.yml
index 74b07e8..d633104 100644
--- a/roles/onos-fabric/tasks/main.yml
+++ b/roles/onos-fabric/tasks/main.yml
@@ -42,4 +42,3 @@
     owner={{ ansible_user }}
     group={{ ansible_user }}
     mode=0644
-    
diff --git a/roles/onos-fabric/vars/main.yml b/roles/onos-fabric/vars/main.yml
index 457d453..bb35dae 100644
--- a/roles/onos-fabric/vars/main.yml
+++ b/roles/onos-fabric/vars/main.yml
@@ -16,5 +16,3 @@
       location:
         leaf: 1
         port: 1
-  
-  
diff --git a/roles/registry/tasks/main.yml b/roles/registry/tasks/main.yml
index e371463..a55ecad 100644
--- a/roles/registry/tasks/main.yml
+++ b/roles/registry/tasks/main.yml
@@ -50,4 +50,5 @@
   command: docker-compose -f /etc/maas/{{ item }} up -d
   with_items:
     - registry-compose.yml
+  changed_when: true
   tags: [registry]