[CORD-1145]
Option to enable apt-cache, conform feature toggles

Change-Id: I560808f4bf292063f9a5d6826b247520e5df3a04
diff --git a/copy-profile-playbook.yml b/copy-profile-playbook.yml
index 17beb92..67c9353 100644
--- a/copy-profile-playbook.yml
+++ b/copy-profile-playbook.yml
@@ -16,11 +16,11 @@
   roles:
     - { role: copy-profile, become: yes }
     - { role: ssh-install, become: yes }
-    - { role: glance-images, become: yes, when: on_maas }
-    - { role: copy-credentials, become: yes, when: on_maas }
+    - { role: glance-images, become: yes, when: use_maas }
+    - { role: copy-credentials, become: yes, when: use_maas }
 
 - name: Install ssh keys when using MaaS
   hosts: build
   roles:
-    - { role: ssh-install-maas, become: yes, when: on_maas }
+    - { role: ssh-install-maas, become: yes, when: use_maas }
 
diff --git a/cord-automation-playbook.yml b/cord-automation-playbook.yml
index 8a5925a..be94e6a 100644
--- a/cord-automation-playbook.yml
+++ b/cord-automation-playbook.yml
@@ -14,5 +14,5 @@
 - name: Set up Automated Compute Node Provisioning
   hosts: head
   roles:
-    - { role: automation-integration, when: on_maas }
+    - { role: automation-integration, when: use_maas }
 
diff --git a/prep-computenode-playbook.yml b/prep-computenode-playbook.yml
index 93ce811..116ff71 100644
--- a/prep-computenode-playbook.yml
+++ b/prep-computenode-playbook.yml
@@ -16,19 +16,19 @@
   become: yes
   roles:
     - common-prep
-    - { role: pki-install, when: not on_maas }
+    - { role: pki-install, when: not use_maas }
 
 - name: Configure management network
   hosts: compute
   become: yes
   roles:
-    - { role: interface-config, when: not on_maas }
+    - { role: interface-config, when: not use_maas }
 
 - name: Use headnode DNS server
   hosts: compute
   become: yes
   roles:
-    - { role: dns-configure, when: not on_maas }
+    - { role: dns-configure, when: not use_maas }
 
 - name: Prep compute node
   hosts: compute
diff --git a/prep-headnode-playbook.yml b/prep-headnode-playbook.yml
index 759a3c3..b1877db 100644
--- a/prep-headnode-playbook.yml
+++ b/prep-headnode-playbook.yml
@@ -32,35 +32,33 @@
   hosts: head
   become: yes
   roles:
-    - { role: interface-config, when: not on_maas }
+    - { role: interface-config, when: not use_maas }
 
 - name: Networking and DNS server on head node
   hosts: head
   become: yes
   roles:
-    - { role: head-mgmtbr, when: not on_maas }
-    - { role: dns-unbound, when: not on_maas }
-    - { role: dns-nsd, when: not on_maas }
+    - { role: head-mgmtbr, when: not use_maas }
+    - { role: dns-unbound, when: not use_maas }
+    - { role: dns-nsd, when: not use_maas }
 
 # needs to be in another set of plays so that nsd/unbound restart handlers run
 - name: Configure DNS resolution, DHCP on head node
   hosts: head
   become: yes
   roles:
-    - { role: dns-configure, when: not on_maas }
-    - { role: dhcpd, when: not on_maas }
+    - { role: dns-configure, when: not use_maas }
+    - { role: dhcpd, when: not use_maas }
 
 - name: Install apt-cacher-ng
   hosts: head
   become: yes
   roles:
-    - apt-cacher-ng
+    - { role: apt-cacher-ng, when: use_apt_cache }
 
-- name: Install elasticstack, and apache proxy
+- name: Install apache proxy
   hosts: head
   become: yes
   roles:
-    - java-oracle
-    - elasticstack
     - apache-proxy
 
diff --git a/profile_manifests/ecord-global.yml b/profile_manifests/ecord-global.yml
index 428b1f5..6a7c237 100644
--- a/profile_manifests/ecord-global.yml
+++ b/profile_manifests/ecord-global.yml
@@ -9,7 +9,8 @@
 deployment_type: MyDeployment
 
 # Feature toggles
-on_maas: True
+use_maas: True
+use_apt_cache: True
 
 # XOS config
 xos_tosca_config_templates:
diff --git a/profile_manifests/ecord.yml b/profile_manifests/ecord.yml
index 140f9a4..28de081 100644
--- a/profile_manifests/ecord.yml
+++ b/profile_manifests/ecord.yml
@@ -9,7 +9,8 @@
 deployment_type: MyDeployment
 
 # Feature toggles
-on_maas: True
+use_maas: True
+use_apt_cache: True
 
 # XOS config
 xos_tosca_config_templates:
diff --git a/profile_manifests/mcord.yml b/profile_manifests/mcord.yml
index 7e83b5f..e934164 100644
--- a/profile_manifests/mcord.yml
+++ b/profile_manifests/mcord.yml
@@ -9,7 +9,8 @@
 deployment_type: MyDeployment
 
 # Feature toggles
-on_maas: True
+use_maas: True
+use_apt_cache: True
 
 # XOS config
 xos_tosca_config_templates:
diff --git a/profile_manifests/rcord.yml b/profile_manifests/rcord.yml
index c54038d..55815f3 100644
--- a/profile_manifests/rcord.yml
+++ b/profile_manifests/rcord.yml
@@ -11,7 +11,8 @@
 
 # Feature toggles
 use_fabric: True
-on_maas: True
+use_maas: True
+use_apt_cache: True
 
 # XOS config
 xos_tosca_config_templates:
diff --git a/roles/compute-prep/defaults/main.yml b/roles/compute-prep/defaults/main.yml
index dc0af11..68d52a6 100644
--- a/roles/compute-prep/defaults/main.yml
+++ b/roles/compute-prep/defaults/main.yml
@@ -5,3 +5,5 @@
 
 pod_sshkey_name: "headnode"
 
+use_maas: False
+
diff --git a/roles/compute-prep/tasks/main.yml b/roles/compute-prep/tasks/main.yml
index 0a5274b..13dc7ab 100644
--- a/roles/compute-prep/tasks/main.yml
+++ b/roles/compute-prep/tasks/main.yml
@@ -16,7 +16,7 @@
     groups: adm
 
 - name: Add pod public key to user accounts
-  when: not on_maas
+  when: not use_maas
   authorized_key:
     user: "{{ item }}"
     key: "{{ lookup('file', '{{ ssh_pki_dir }}/client_certs/{{ pod_sshkey_name }}_sshkey.pub') }}"
@@ -25,7 +25,7 @@
     - ubuntu
 
 - name: Add pod public key to user accounts (MaaS)
-  when: on_maas
+  when: use_maas
   authorized_key:
     user: "{{ item }}"
     key: "{{ lookup('file', '/opt/cord_profile/node_key.pub') }}"
@@ -34,7 +34,7 @@
     - ubuntu
 
 - name: Copy over CA certs from head node (MaaS)
-  when: on_maas
+  when: use_maas
   synchronize:
     src: "/usr/local/share/ca-certificates/"
     dest: "/usr/local/share/ca-certificates/"
diff --git a/roles/cord-profile/defaults/main.yml b/roles/cord-profile/defaults/main.yml
index 0f71033..6a30e58 100644
--- a/roles/cord-profile/defaults/main.yml
+++ b/roles/cord-profile/defaults/main.yml
@@ -22,7 +22,7 @@
 use_openstack: True
 
 # Will be overridden if doing a full pod build
-on_maas: False
+use_maas: False
 
 # set to True to create the xos_redis container in the bootstrap context
 use_redis: True
diff --git a/roles/create-lxd/defaults/main.yml b/roles/create-lxd/defaults/main.yml
index 891ed45..f4974cb 100644
--- a/roles/create-lxd/defaults/main.yml
+++ b/roles/create-lxd/defaults/main.yml
@@ -10,3 +10,4 @@
 hwaddr_prefix: "c2a4"
 mgmt_ipv4_first_octets: "192.168.200"
 
+use_maas: False
diff --git a/roles/create-lxd/tasks/main.yml b/roles/create-lxd/tasks/main.yml
index ecf095a..b27e08c 100644
--- a/roles/create-lxd/tasks/main.yml
+++ b/roles/create-lxd/tasks/main.yml
@@ -55,19 +55,19 @@
   with_items: "{{ head_lxd_list }}"
 
 - name: fetch IP of DHCP harvester
-  when: on_maas
+  when: use_maas
   command: docker-ip harvester
   register: harvester_ip
   changed_when: False
 
 - name: force a harvest to get container name resolution
-  when: on_maas
+  when: use_maas
   uri:
     url: http://{{ harvester_ip.stdout }}:8954/harvest
     method: POST
 
 - name: wait for container name resolution
-  when: on_maas
+  when: use_maas
   host_dns_check:
     hosts: "{{ head_lxd_list | map(attribute='name') | list | to_json }}"
     command_on_fail: "curl -sS --connect-timeout 3 -XPOST http://{{ harvester_ip.stdout }}:8954/harvest"
diff --git a/roles/head-prep/defaults/main.yml b/roles/head-prep/defaults/main.yml
index 17a4e22..f6ac6cc 100644
--- a/roles/head-prep/defaults/main.yml
+++ b/roles/head-prep/defaults/main.yml
@@ -1,7 +1,7 @@
 ---
 # head-prep/defaults/main.yml
 
-on_maas: false
+use_maas: false
 
 ssh_pki_dir: "{{ playbook_dir }}/ssh_pki"
 ssh_keytype: rsa
diff --git a/roles/lxd-finish/defaults/main.yml b/roles/lxd-finish/defaults/main.yml
index 0f65371..619335d 100644
--- a/roles/lxd-finish/defaults/main.yml
+++ b/roles/lxd-finish/defaults/main.yml
@@ -1,6 +1,8 @@
 ---
 # lxd-finish/defaults/main.yml
 
+use_apt_cache: True
+
 apt_cacher_name: apt-cache
 
 run_dist_upgrade: False
diff --git a/roles/lxd-finish/tasks/main.yml b/roles/lxd-finish/tasks/main.yml
index 4c02bce..d3fa47b 100644
--- a/roles/lxd-finish/tasks/main.yml
+++ b/roles/lxd-finish/tasks/main.yml
@@ -25,6 +25,7 @@
     - skip_ansible_lint # running a sub job
 
 - name: Have containers use the apt-cache
+  when: use_apt_cache
   command: >
     ansible containers -b -u ubuntu
      -m lineinfile
diff --git a/roles/ssh-install-maas/defaults/main.yml b/roles/ssh-install-maas/defaults/main.yml
index 15abf98..41cbff6 100644
--- a/roles/ssh-install-maas/defaults/main.yml
+++ b/roles/ssh-install-maas/defaults/main.yml
@@ -8,4 +8,4 @@
 # name of master ssh key for this pod
 pod_sshkey_name: "headnode"
 
-on_maas: False
+use_maas: False
diff --git a/roles/ssh-install-maas/tasks/main.yml b/roles/ssh-install-maas/tasks/main.yml
index 96d952d..f47ce35 100644
--- a/roles/ssh-install-maas/tasks/main.yml
+++ b/roles/ssh-install-maas/tasks/main.yml
@@ -5,7 +5,7 @@
 # users/perms may seem off, but is identical to that role
 
 - name: Create ssh key directory for MaaS
-  when: on_maas
+  when: use_maas
   file:
     dest: "/etc/maas/.ssh/"
     mode: 0755
@@ -14,7 +14,7 @@
     state: directory
 
 - name: Copy ssh private key for MaaS
-  when: on_maas
+  when: use_maas
   copy:
     src: "{{ ssh_pki_dir }}/client_certs/{{ pod_sshkey_name }}_sshkey"
     dest: "/etc/maas/.ssh/cord_rsa"
@@ -24,7 +24,7 @@
     backup: true
 
 - name: Copy ssh public key for MaaS
-  when: on_maas
+  when: use_maas
   copy:
     src: "{{ ssh_pki_dir }}/client_certs/{{ pod_sshkey_name }}_sshkey.pub"
     dest: "/etc/maas/.ssh/cord_rsa.pub"
diff --git a/roles/ssh-install/defaults/main.yml b/roles/ssh-install/defaults/main.yml
index 1fbddfa..5459cd4 100644
--- a/roles/ssh-install/defaults/main.yml
+++ b/roles/ssh-install/defaults/main.yml
@@ -8,4 +8,4 @@
 # name of master ssh key for this pod
 pod_sshkey_name: "headnode"
 
-on_maas: False
+use_maas: False