ansible / ansible-container

DEPRECATED -- Ansible Container was a tool to build Docker images and orchestrate containers using only Ansible playbooks.
GNU Lesser General Public License v3.0
2.19k stars 392 forks source link

Can't find some galaxy roles #705

Open alexppg opened 7 years ago

alexppg commented 7 years ago
ISSUE TYPE
container.yml
version: "2"
settings:
  conductor:
    base: ubuntu:16.04
  project_name: php7-ubuntu

services:
  base:
    from        : ubuntu:16.04
    command     :
      - /bin/bash

    roles:
      - bennojoy.memcached
OS / ENVIRONMENT
Ansible Container, version 0.9.2rc0
Linux, notebook, 4.9.0-3-amd64, #1 SMP Debian 4.9.30-2+deb9u3 (2017-08-06), x86_64
2.7.13 (default, Jan 19 2017, 14:48:08) 
[GCC 6.3.0 20170118] /usr/bin/python
{
  "ContainersPaused": 0, 
  "Labels": null, 
  "CgroupDriver": "cgroupfs", 
  "ContainersRunning": 0, 
  "ContainerdCommit": {
    "Expected": "cfb82a876ecc11b5ca0977d1733adbe58599088a", 
    "ID": "cfb82a876ecc11b5ca0977d1733adbe58599088a"
  }, 
  "InitBinary": "docker-init", 
  "NGoroutines": 26, 
  "Swarm": {
    "ControlAvailable": false, 
    "NodeID": "", 
    "Error": "", 
    "RemoteManagers": null, 
    "LocalNodeState": "inactive", 
    "NodeAddr": ""
  }, 
  "LoggingDriver": "json-file", 
  "OSType": "linux", 
  "HttpProxy": "", 
  "Runtimes": {
    "runc": {
      "path": "docker-runc"
    }
  }, 
  "DriverStatus": [
    [
      "Backing Filesystem", 
      "extfs"
    ], 
    [
      "Supports d_type", 
      "true"
    ], 
    [
      "Native Overlay Diff", 
      "true"
    ]
  ], 
  "OperatingSystem": "Debian GNU/Linux 9 (stretch)", 
  "Containers": 159, 
  "HttpsProxy": "", 
  "BridgeNfIp6tables": true, 
  "MemTotal": 16760045568, 
  "SecurityOptions": [
    "name=seccomp,profile=default"
  ], 
  "Driver": "overlay2", 
  "IndexServerAddress": "https://index.docker.io/v1/", 
  "ClusterStore": "", 
  "InitCommit": {
    "Expected": "949e6fa", 
    "ID": "949e6fa"
  }, 
  "Isolation": "", 
  "SystemStatus": null, 
  "OomKillDisable": true, 
  "ClusterAdvertise": "", 
  "SystemTime": "2017-08-17T08:40:39.921532499+02:00", 
  "Name": "notebook", 
  "CPUSet": true, 
  "RegistryConfig": {
    "AllowNondistributableArtifactsCIDRs": [], 
    "Mirrors": [], 
    "IndexConfigs": {
      "docker.io": {
        "Official": true, 
        "Name": "docker.io", 
        "Secure": true, 
        "Mirrors": []
      }
    }, 
    "AllowNondistributableArtifactsHostnames": [], 
    "InsecureRegistryCIDRs": [
      "127.0.0.0/8"
    ]
  }, 
  "DefaultRuntime": "runc", 
  "ContainersStopped": 159, 
  "NCPU": 8, 
  "NFd": 17, 
  "Architecture": "x86_64", 
  "KernelMemory": true, 
  "CpuCfsQuota": true, 
  "Debug": false, 
  "ID": "YEYW:FXKT:2HOB:S242:BQCA:E3OB:ADSH:CU6E:JUVN:S66Y:MONE:FNUB", 
  "IPv4Forwarding": true, 
  "KernelVersion": "4.9.0-3-amd64", 
  "BridgeNfIptables": true, 
  "NoProxy": "", 
  "LiveRestoreEnabled": false, 
  "ServerVersion": "17.06.0-ce", 
  "CpuCfsPeriod": true, 
  "ExperimentalBuild": false, 
  "MemoryLimit": true, 
  "SwapLimit": false, 
  "Plugins": {
    "Volume": [
      "local"
    ], 
    "Network": [
      "bridge", 
      "host", 
      "macvlan", 
      "null", 
      "overlay"
    ], 
    "Authorization": null, 
    "Log": [
      "awslogs", 
      "fluentd", 
      "gcplogs", 
      "gelf", 
      "journald", 
      "json-file", 
      "logentries", 
      "splunk", 
      "syslog"
    ]
  }, 
  "Images": 13, 
  "DockerRootDir": "/var/lib/docker", 
  "NEventsListener": 0, 
  "CPUShares": true, 
  "RuncCommit": {
    "Expected": "2d41c047c83e09a6d61d464906feb2a2f3c52aa4", 
    "ID": "2d41c047c83e09a6d61d464906feb2a2f3c52aa4"
  }
}
{
  "KernelVersion": "4.9.0-3-amd64", 
  "Arch": "amd64", 
  "BuildTime": "2017-06-23T21:16:12.825866885+00:00", 
  "ApiVersion": "1.30", 
  "Version": "17.06.0-ce", 
  "MinAPIVersion": "1.12", 
  "GitCommit": "02c1d87", 
  "Os": "linux", 
  "GoVersion": "go1.8.3"
}
SUMMARY

Ansible-container doesn't detect some galaxy roles. I can't find a pattern on why this happens.

STEPS TO REPRODUCE

First install some galaxy roles. I've tried with:

For some reason, it worked as expected with the role bennojoy.mysql, but only when changing the roles section on the container.yml file. Instead of using the bennojoy.mysql, it must be used mysql:

ansible-galaxy install bennojoy.mysql
version: "2"
settings:
  conductor:
    base: ubuntu:16.04
  project_name: php7-ubuntu

services:
  base:
    from        : ubuntu:16.04
    command     :
      - /bin/bash

    roles:
      - mysql

To reproduce it just install the roles with standard ansible-galaxy install franklinkim.nginx and execute ansible-container.

EXPECTED RESULTS

It should detect the roles.

ACTUAL RESULTS
Starting Docker build of Ansible Container Conductor image (please be patient)...   
Parsing conductor CLI args.
Traceback (most recent call last):
  File "/usr/local/bin/conductor", line 11, in <module>
    load_entry_point('ansible-container', 'console_scripts', 'conductor')()
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/cli.py", line 382, in conductor_commandline
    conductor_config = AnsibleContainerConductorConfig(list_to_ordereddict(containers_config))
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/config.py", line 292, in __init__
    self._process_services()
  File "/_ansible/container/config.py", line 352, in _process_services
    role_metadata = get_metadata_from_role(role_name)
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/utils/__init__.py", line 275, in get_metadata_from_role
    return get_content_from_role(role_name, os.path.join('meta', 'container.yml'))
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/utils/__init__.py", line 264, in get_content_from_role
    role_path = resolve_role_to_path(role_name)
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/utils/__init__.py", line 210, in resolve_role_to_path
    loader=loader)
  File "/usr/local/lib/python2.7/dist-packages/ansible/playbook/role/include.py", line 59, in load
    return ri.load_data(data, variable_manager=variable_manager, loader=loader)
  File "/usr/local/lib/python2.7/dist-packages/ansible/playbook/base.py", line 243, in load_data
    ds = self.preprocess_data(ds)
  File "/usr/local/lib/python2.7/dist-packages/ansible/playbook/role/definition.py", line 94, in preprocess_data
    (role_name, role_path) = self._load_role_path(role_name)
  File "/usr/local/lib/python2.7/dist-packages/ansible/playbook/role/definition.py", line 187, in _load_role_path
    raise AnsibleError("the role '%s' was not found in %s" % (role_name, ":".join(role_search_paths)), obj=self._ds)
ansible.errors.AnsibleError: the role 'bennojoy.memcached' was not found in ./roles:/src/roles:/etc/ansible/roles:.
Conductor terminated. Cleaning up.  command_rc=1 conductor_id=ef029cda1c794b36f7fc030cf73b666a15d2e9f8aa957b2c6f316441cf06a34a save_container=False
ERROR   Conductor exited with status 1  

PD: I tried changing the roles to other paths I know for sure are detected and still the same.

alexppg commented 7 years ago

Actually, I first tried symlinking them to other paths that worked and still didn't worked, but I've just tried plain copy and it worked.

chouseknecht commented 7 years ago

You have to install the roles to the 'roles' folder in base_path (the project's root directory). Or, add them to requirements.yml, so that they get installed into the conductor. Or, use --roles-path to mount an external path (one outside of your project) to the conductor.

Did you try any of these?

j00bar commented 7 years ago

Yeah, because builds are being executed in a containerized environment, symlinks to paths outside of the project path or to absolute paths within the project path won't do what you think they'd do.

alexppg commented 7 years ago

When copied on the same path, in the requirements.yml or using --roles-path, it works as expected. But when using none of them, the paths where it searches for roles is ./roles:/src/roles:/etc/ansible/roles: (on the host, not on the conductor), as you can see on the above error. If it's correct that it doesn't search /etc/ansible/roles, then maybe that path could be removed from the error? It makes you think that it's not finding them.