Repository: ansible/ansible

Issue:
ansible-galaxy info display 'galaxy_info' label 1 char per line
##### ISSUE TYPE
- Bug Report
##### ANSIBLE VERSION

```
ansible 2.1.0 (devel 03300e99ac) last updated 2016/03/26 14:27:03 (GMT -400)
  lib/ansible/modules/core: (detached HEAD 345d9cbca8) last updated 2016/03/26 14:27:07 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD f9b96b9a8a) last updated 2016/03/26 14:27:10 (GMT -400)
  config file = /Users/adrian/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```
##### CONFIGURATION

env:
ANSIBLE_CONFIG=/Users/adrian/ansible/ansible.cfg
ANSIBLE_HOME=/Users/adrian/src/alikins-ansible

ansible.cfg:

``` INI
[defaults]
inventory = $HOME/ansible/hosts
log_path = $HOME/ansible/log/ansible.log
roles_path = $HOME/ansible/galaxy-roles:$HOME/ansible/roles

[ssh_connection]
# NOTE: Is there a way to inherit these settings?
ssh_args = -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=300s -o ControlPath=/tmp/ansible-ssh-%h-%p-%r
```
##### OS / ENVIRONMENT

RHEL 7.2-(ish), Centos 7.2, OSX 10.10.5 (Yosemite)
##### SUMMARY

Running 'ansible-galaxy info' on a install galaxy roles causes the label for 'galaxy_info' section to be display one char per line.
##### STEPS TO REPRODUCE

``` shell
$ # The role doesn't seem to matter
$ ansible-galaxy install geerlingguy.daemonize
$ ansible-galaxy info geerlingguy.daemonize
```

<!--- You can also paste gist.github.com links for larger files -->
##### EXPECTED RESULTS

Properly formatted output, ala

``` shell
Role: geerlingguy.daemonize
        description: Daemonize for Unix-like operating systems
        active: True
        commit: 3991e921f5ab00a1211777fa1b85298f4ecc2e36
        commit_message: Ensure which is installed on RHEL.
        commit_url: https://github.com/geerlingguy/ansible-role-daemonize/commit/3991e921f5ab00a1211777fa1b85298f4ecc2e36
        company: Midwestern Mac, LLC
        created: 2014-12-17T15:19:52.988Z
        dependencies: []
        download_count: 6829
        forks_count: 6
        galaxy_info:
                author: geerlingguy
                company: Midwestern Mac, LLC
                galaxy_tags: ['development', 'web', 'system', 'mail']
                license: license (BSD, MIT)
                min_ansible_version: 1.6
                platforms: [{'name': 'EL', 'versions': ['all']}, {'name': 'Ubuntu', 'versions': ['all']}, {'name': 'Debian', 'versions': ['all']}, {'name': '
        github_branch: 
        github_repo: ansible-role-daemonize
        github_user: geerlingguy
<... cut for brevity ...>
```
##### ACTUAL RESULTS

``` shell
[vagrant@localhost ansible]$ ansible-galaxy install geerlingguy.daemonize
- downloading role 'daemonize', owned by geerlingguy
- downloading role from https://github.com/geerlingguy/ansible-role-daemonize/archive/1.1.0.tar.gz
- extracting geerlingguy.daemonize to /home/vagrant/ansible/roles/geerlingguy.daemonize
- geerlingguy.daemonize was installed successfully
[vagrant@localhost ansible]$ ansible-galaxy info geerlingguy.daemonize
[DEPRECATION WARNING]: The comma separated role spec format, use the yaml/explicit format instead..
This feature will be removed in a future release. 
Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
less 458 (POSIX regular expressions)
Copyright (C) 1984-2012 Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Homepage: http://www.greenwoodsoftware.com/less

Role: geerlingguy.daemonize
        description: Daemonize for Unix-like operating systems
        active: True
        commit: 3991e921f5ab00a1211777fa1b85298f4ecc2e36
        commit_message: Ensure which is installed on RHEL.
        commit_url: https://github.com/geerlingguy/ansible-role-daemonize/commit/3991e921f5ab00a1211777fa1b85298f4ecc2e36
        company: Midwestern Mac, LLC
        created: 2014-12-17T15:19:52.988Z
        dependencies: []
        download_count: 6829
        forks_count: 6

g
a
l
a
x
y
_
i
n
f
o
:



        galaxy_info:
                author: geerlingguy
                company: Midwestern Mac, LLC
                galaxy_tags: ['development', 'web', 'system', 'mail']
                license: license (BSD, MIT)
                min_ansible_version: 1.6
                platforms: [{'name': 'EL', 'versions': ['all']}, {'name': 'Ubuntu', 'versions': ['all']}, {'name': 'Debian', 'versions': ['all']}, {'name': '
        github_branch: 
        github_repo: ansible-role-daemonize
        github_user: geerlingguy
        id: 2433
        install_date: Sat Mar 26 18:46:25 2016
        intalled_version: 1.1.0
        is_valid: True
        issue_tracker_url: https://api.github.com/repos/geerlingguy/ansible-role-daemonize/issues{/number}
        license: license (BSD, MIT)
```

The label for 'galaxy_info' is displayed one char at a time instead as a single line.
I have a patch for this ready to go.



Discussion:

Resolving patch:
diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py
--- a/lib/ansible/cli/galaxy.py
+++ b/lib/ansible/cli/galaxy.py
@@ -152,7 +152,6 @@ def _display_role_info(self, role_info):
                 continue
 
             if isinstance(role_info[k], dict):
-                text += "\t%s: \n" % (k)
                 text.append(u"\t%s:" % (k))
                 for key in sorted(role_info[k].keys()):
                     if key in self.SKIP_INFO_KEYS:


Test patch:
diff --git a/test/units/cli/__init__.py b/test/units/cli/__init__.py
new file mode 100644
diff --git a/test/units/cli/test_galaxy.py b/test/units/cli/test_galaxy.py
new file mode 100644
--- /dev/null
+++ b/test/units/cli/test_galaxy.py
@@ -0,0 +1,53 @@
+# (c) 2016, Adrian Likins <alikins@redhat.com>
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.
+
+# Make coding more python3-ish
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+from ansible.compat.six import PY3
+from ansible.compat.tests import unittest
+
+from nose.plugins.skip import SkipTest
+
+if PY3:
+    raise SkipTest('galaxy is not ported to be py3 compatible yet')
+
+from ansible.cli.galaxy import GalaxyCLI
+
+class TestGalaxy(unittest.TestCase):
+    def setUp(self):
+        self.default_args = []
+
+    def test_init(self):
+        galaxy_cli = GalaxyCLI(args=self.default_args)
+        self.assertTrue(isinstance(galaxy_cli, GalaxyCLI))
+
+    def test_display_min(self):
+        gc = GalaxyCLI(args=self.default_args)
+        role_info = {'name': 'some_role_name'}
+        display_result = gc._display_role_info(role_info)
+        self.assertTrue(display_result.find('some_role_name') >-1)
+
+    def test_display_galaxy_info(self):
+        gc = GalaxyCLI(args=self.default_args)
+        galaxy_info = {}
+        role_info = {'name': 'some_role_name',
+                     'galaxy_info': galaxy_info}
+        display_result = gc._display_role_info(role_info)
+        if display_result.find('\t\tgalaxy_tags:') > -1:
+            self.fail('Expected galaxy_tags to be indented twice')