New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation warnings from Ansible if running Ansible 2.4+ #1553

Closed
geerlingguy opened this Issue Sep 19, 2017 · 18 comments

Comments

8 participants
@geerlingguy
Owner

geerlingguy commented Sep 19, 2017

Issue Type

  • Bug Report

Full console output

[DEPRECATION WARNING]: The use of 'include' for tasks has been deprecated. Use 
'import_tasks' for static inclusions or 'include_tasks' for dynamic inclusions.
 This feature will be removed in a future release. Deprecation warnings can be 
disabled by setting deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: include is kept for backwards compatibility but usage is
 discouraged. The module documentation details page may explain more about this
 rationale.. This feature will be removed in a future release. Deprecation 
warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: The use of 'static' has been deprecated. Use 
'import_tasks' for static inclusion, or 'include_tasks' for dynamic inclusion. 
This feature will be removed in a future release. Deprecation warnings can be 
disabled by setting deprecation_warnings=False in ansible.cfg.
 [WARNING]: file /Users/jeff.geerling/Dropbox/Development/GitHub/drupal-
vm/provisioning/roles/geerlingguy.apache-php-fpm/tasks/configure-RedHat.yml is
empty and had no tasks to include

Summary

There are a few warnings that occur when running Drupal VM's playbook under Ansible 2.4.0+ (released today):

  • [defaults]hostfile option, The key is misleading as it can also be a list of hosts, a directory or a list of paths . This feature will be removed in version 2.8. (This was from my own ansible.cfg file, not Drupal VM's—fix is to switch hostfile to inventory under the [defaults] section in ansible.cfg.)
  • The use of 'include' for tasks has been deprecated. Use 'import_tasks' for static inclusions or 'include_tasks' for dynamic inclusions. This feature will be removed in a future release. (same with 'static)
  • (And in Ansible 2.5+) [DEPRECATION WARNING]: State 'installed' is deprecated. Using state 'present' instead.. This feature will be removed in version 2.9. Fixed.

It looks like we're hitting a chicken-and-egg issue again (like with 2.0->2.2) where something is deprecated, but if I fix it, then anyone using < 2.4.0 will not be able to run the playbook. So do I force everyone everywhere to upgrade to 2.4.0 now, or do I wait and live with the deprecation warnings... And the inevitable slew of issues people will report saying "Drupal VM is broken, it is scary, make these warnings go away!"

Roles to update for include deprecation

  • franklinkim.newrelic (need to submit a PR upstream)
  • geerlingguy.varnish
  • geerlingguy.apache
  • geerlingguy.mysql
  • geerlingguy.php
  • geerlingguy.postgresql
  • geerlingguy.blackfire
  • geerlingguy.composer
  • geerlingguy.elasticsearch
  • geerlingguy.java
  • geerlingguy.drupal
  • geerlingguy.drush
  • geerlingguy.firewall
  • geerlingguy.nodejs
  • geerlingguy.php-redis
  • geerlingguy.php-tideways
  • geerlingguy.php-versions
  • geerlingguy.php-xhprof
  • geerlingguy.redis
  • geerlingguy.ruby
  • geerlingguy.security
@oxyc

This comment has been minimized.

Show comment
Hide comment
@oxyc

oxyc Sep 19, 2017

Collaborator

Auch. Are you considering making 2.4.0 a requirements in all your roles? If not, maybe just hide those deprecation warnings for users running the playbook through Vagrant (meaning travis still logs them at least).

diff --git a/Vagrantfile b/Vagrantfile
index 774121e..bb20d7b 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -29,9 +29,11 @@ vconfig = load_config([

 provisioner = vconfig['force_ansible_local'] ? :ansible_local : vagrant_provisioner
 if provisioner == :ansible
+  ansible_config_file = "#{host_drupalvm_dir}/provisioning/ansible.cfg"
   playbook = "#{host_drupalvm_dir}/provisioning/playbook.yml"
   config_dir = host_config_dir
 else
+  ansible_config_file = "#{guest_drupalvm_dir}/provisioning/ansible.cfg"
   playbook = "#{guest_drupalvm_dir}/provisioning/playbook.yml"
   config_dir = guest_config_dir
 end
@@ -103,6 +105,8 @@ Vagrant.configure('2') do |config|
   end

   config.vm.provision provisioner do |ansible|
+    ansible.config_file = ansible_config_file unless ENV['DRUPALVM_DEBUG']
+    ansible.verbose = ENV['DRUPALVM_DEBUG']
     ansible.playbook = playbook
     ansible.extra_vars = {
       config_dir: config_dir,
diff --git a/provisioning/ansible.cfg b/provisioning/ansible.cfg
index 4b1740e..a43fedc 100644
--- a/provisioning/ansible.cfg
+++ b/provisioning/ansible.cfg
@@ -1,5 +1,6 @@
 [defaults]
 roles_path = ./roles
+deprecation_warnings = False

 [ssh_connection]
 pipelining = True

Then you would enable debug mode with DRUPALVM_DEBUG=1 vagrant provision or verbose ansible output with DRUPALVM_DEBUG=vvv vagrant-provision

Collaborator

oxyc commented Sep 19, 2017

Auch. Are you considering making 2.4.0 a requirements in all your roles? If not, maybe just hide those deprecation warnings for users running the playbook through Vagrant (meaning travis still logs them at least).

diff --git a/Vagrantfile b/Vagrantfile
index 774121e..bb20d7b 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -29,9 +29,11 @@ vconfig = load_config([

 provisioner = vconfig['force_ansible_local'] ? :ansible_local : vagrant_provisioner
 if provisioner == :ansible
+  ansible_config_file = "#{host_drupalvm_dir}/provisioning/ansible.cfg"
   playbook = "#{host_drupalvm_dir}/provisioning/playbook.yml"
   config_dir = host_config_dir
 else
+  ansible_config_file = "#{guest_drupalvm_dir}/provisioning/ansible.cfg"
   playbook = "#{guest_drupalvm_dir}/provisioning/playbook.yml"
   config_dir = guest_config_dir
 end
@@ -103,6 +105,8 @@ Vagrant.configure('2') do |config|
   end

   config.vm.provision provisioner do |ansible|
+    ansible.config_file = ansible_config_file unless ENV['DRUPALVM_DEBUG']
+    ansible.verbose = ENV['DRUPALVM_DEBUG']
     ansible.playbook = playbook
     ansible.extra_vars = {
       config_dir: config_dir,
diff --git a/provisioning/ansible.cfg b/provisioning/ansible.cfg
index 4b1740e..a43fedc 100644
--- a/provisioning/ansible.cfg
+++ b/provisioning/ansible.cfg
@@ -1,5 +1,6 @@
 [defaults]
 roles_path = ./roles
+deprecation_warnings = False

 [ssh_connection]
 pipelining = True

Then you would enable debug mode with DRUPALVM_DEBUG=1 vagrant provision or verbose ansible output with DRUPALVM_DEBUG=vvv vagrant-provision

@fubarhouse

This comment has been minimized.

Show comment
Hide comment
@fubarhouse

fubarhouse Sep 20, 2017

So when Ansible 2.8 hits, include will be removed from Ansible.

Is there a task to at least migrate associated tasks and roles to the new standard - so nothing is forgotten?

I know this will impact me quite a lot, though because the new pieces of functionality didn't exist in 2.3, making 2.4 mandatory would be dangerous.

fubarhouse commented Sep 20, 2017

So when Ansible 2.8 hits, include will be removed from Ansible.

Is there a task to at least migrate associated tasks and roles to the new standard - so nothing is forgotten?

I know this will impact me quite a lot, though because the new pieces of functionality didn't exist in 2.3, making 2.4 mandatory would be dangerous.

@oxyc

This comment has been minimized.

Show comment
Hide comment
@oxyc

oxyc Sep 20, 2017

Collaborator

Ansible is developed and released on a flexible 4 months release cycle.

So that means 2.8 will be released early 2019.

Collaborator

oxyc commented Sep 20, 2017

Ansible is developed and released on a flexible 4 months release cycle.

So that means 2.8 will be released early 2019.

@danbohea

This comment has been minimized.

Show comment
Hide comment
@danbohea

danbohea Oct 21, 2017

Contributor

I'm curious as to what the exact fix is for the first warning (I'm experiencing this same warning in other playbooks besides DVM):

[DEPRECATION WARNING]: [defaults]hostfile option, The key is misleading as it 
can also be a list of hosts, a directory or a list of paths . This feature will
 be removed in version 2.8. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.

At least with the other warnings it gives you some suggestions as to how you might go about addressing the issue.

Contributor

danbohea commented Oct 21, 2017

I'm curious as to what the exact fix is for the first warning (I'm experiencing this same warning in other playbooks besides DVM):

[DEPRECATION WARNING]: [defaults]hostfile option, The key is misleading as it 
can also be a list of hosts, a directory or a list of paths . This feature will
 be removed in version 2.8. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.

At least with the other warnings it gives you some suggestions as to how you might go about addressing the issue.

@iAugur

This comment has been minimized.

Show comment
Hide comment
@iAugur

iAugur Nov 10, 2017

In most cases simply change it from hostfile to inventory

[default]
#hostfile = ./inventory/common/allhosts
inventory = ./inventory/common/allhosts

iAugur commented Nov 10, 2017

In most cases simply change it from hostfile to inventory

[default]
#hostfile = ./inventory/common/allhosts
inventory = ./inventory/common/allhosts
@danbohea

This comment has been minimized.

Show comment
Hide comment
@danbohea

danbohea Nov 10, 2017

Contributor

@iAugur Yeah, I've already done exactly that in a few playbooks but my linter is still complaining - I'm gonna put that down to a shortcoming of the linter for now.

Contributor

danbohea commented Nov 10, 2017

@iAugur Yeah, I've already done exactly that in a few playbooks but my linter is still complaining - I'm gonna put that down to a shortcoming of the linter for now.

@wturrell

This comment has been minimized.

Show comment
Hide comment
@wturrell

wturrell Dec 12, 2017

For the benefit of others, especially if you don't edit your ansible.cfg very often, it may be hidden, named as .ansible.cfg (in your home directory).

wturrell commented Dec 12, 2017

For the benefit of others, especially if you don't edit your ansible.cfg very often, it may be hidden, named as .ansible.cfg (in your home directory).

@ElijahLynn

This comment has been minimized.

Show comment
Hide comment
@ElijahLynn

ElijahLynn Dec 14, 2017

Also for the benefit of others, if you have a closer ansible.cfg in your directory hierarchy, it will choose that one and NOT merge the two together. So if you have an ansible.cfg in your playbook directory, setting deprecation_warnings=false in /etc/ansible/ansible.cfg will do nothing even if that setting isn't specified in your ansible.cfg in the playbook dir. I know this is obvious to some but hey, here I am.

ElijahLynn commented Dec 14, 2017

Also for the benefit of others, if you have a closer ansible.cfg in your directory hierarchy, it will choose that one and NOT merge the two together. So if you have an ansible.cfg in your playbook directory, setting deprecation_warnings=false in /etc/ansible/ansible.cfg will do nothing even if that setting isn't specified in your ansible.cfg in the playbook dir. I know this is obvious to some but hey, here I am.

@geerlingguy

This comment has been minimized.

Show comment
Hide comment
@geerlingguy
Owner

geerlingguy commented Dec 17, 2017

@danbohea

This comment has been minimized.

Show comment
Hide comment
@danbohea

danbohea Feb 7, 2018

Contributor

Also, also, for the benefit of others, the source of my particular issue was that I was still exporting ANSIBLE_HOSTS in my .bash_profile e.g:

# This is now deprecated.
export ANSIBLE_HOSTS=$HOME/some/path
Contributor

danbohea commented Feb 7, 2018

Also, also, for the benefit of others, the source of my particular issue was that I was still exporting ANSIBLE_HOSTS in my .bash_profile e.g:

# This is now deprecated.
export ANSIBLE_HOSTS=$HOME/some/path
@geerlingguy

This comment has been minimized.

Show comment
Hide comment
@geerlingguy

geerlingguy Mar 2, 2018

Owner

See #1701 as well—we've bumped the version to 2.4, so I feel like I might start bumping a few more of my roles too. But until all are updated (that will take a while...) the deprecation warnings will persist for those who don't disable them.

Owner

geerlingguy commented Mar 2, 2018

See #1701 as well—we've bumped the version to 2.4, so I feel like I might start bumping a few more of my roles too. But until all are updated (that will take a while...) the deprecation warnings will persist for those who don't disable them.

@geerlingguy

This comment has been minimized.

Show comment
Hide comment
@geerlingguy

geerlingguy Apr 24, 2018

Owner

If fixed the deprecated uses in Drupal VM's own tasks/playbooks, and am slowly working through all my roles to remove deprecated uses there (it looks like varnish, drupal, mysql, php, postgresql, and security are the worst offenders...).

I noticed franklinkim.newrelic is also in the list of roles using includes... might file a PR to get those fixed too, but will have to wait on @franklinkim to merge if he wants (and make his role 2.4+ as well).

Owner

geerlingguy commented Apr 24, 2018

If fixed the deprecated uses in Drupal VM's own tasks/playbooks, and am slowly working through all my roles to remove deprecated uses there (it looks like varnish, drupal, mysql, php, postgresql, and security are the worst offenders...).

I noticed franklinkim.newrelic is also in the list of roles using includes... might file a PR to get those fixed too, but will have to wait on @franklinkim to merge if he wants (and make his role 2.4+ as well).

@franklinkim

This comment has been minimized.

Show comment
Hide comment
@franklinkim

franklinkim Apr 25, 2018

@geerlingguy I updated the includes in my role.

franklinkim commented Apr 25, 2018

@geerlingguy I updated the includes in my role.

@geerlingguy

This comment has been minimized.

Show comment
Hide comment
@geerlingguy

geerlingguy Apr 25, 2018

Owner

@franklinkim - Awesome! Thanks for the quick work, saves me the time in filing a PR :)

Owner

geerlingguy commented Apr 25, 2018

@franklinkim - Awesome! Thanks for the quick work, saves me the time in filing a PR :)

@geerlingguy

This comment has been minimized.

Show comment
Hide comment
@geerlingguy

geerlingguy Apr 27, 2018

Owner

Just one more role... Ruby. Always Ruby causing trouble... automated tests for source install are failing, but once that's fixed I'll tag a new release and be done with it!

Owner

geerlingguy commented Apr 27, 2018

Just one more role... Ruby. Always Ruby causing trouble... automated tests for source install are failing, but once that's fixed I'll tag a new release and be done with it!

@geerlingguy

This comment has been minimized.

Show comment
Hide comment
@geerlingguy

geerlingguy Apr 27, 2018

Owner

Ruby role is complete. Running locally to see if all the warnings are gone... fingers crossed!

Owner

geerlingguy commented Apr 27, 2018

Ruby role is complete. Running locally to see if all the warnings are gone... fingers crossed!

@geerlingguy

This comment has been minimized.

Show comment
Hide comment
@geerlingguy

geerlingguy Apr 27, 2018

Owner

This is fixed, yay!

Owner

geerlingguy commented Apr 27, 2018

This is fixed, yay!

@fubarhouse

This comment has been minimized.

Show comment
Hide comment
@fubarhouse

fubarhouse Apr 28, 2018

Nice one! I suppose I can't delay working my way through all my roles too then :P

fubarhouse commented Apr 28, 2018

Nice one! I suppose I can't delay working my way through all my roles too then :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment