How to a activate ONOS apps by ansible-playbook?

5 views
Skip to first unread message

Ivy Min

unread,
Jan 24, 2020, 11:51:38 AM1/24/20
to Ansible Project

My ansible-playbook version is latest. I try to activate ONOS service in docker container by running ansible-playbook. I tried some ways. However they all failed.

---
- hosts: local
  tasks:
  - name: Create a onos-a container
    docker_container:
      name: onos-a
      image: onosproject/onos 
      restart: yes
      ports: 8190:8190 

  - name: Activate onos-a fwd apps #failed by shell
    shell: "docker exec -it onos-a bash -c '/root/onos/apache-karaf-4.2.6/bin/client app activate org.onosproject.openflow'"
    become: yes
  - name: Activate onos-a apps #fialed by commands
    docker_container:
       name: onos-a
       command: export ONOS_APPS=fwd
       command: export ONOS_APPS=openflow

Need some help ~

when I running shell command, the error shows

   "changed": true, 
    "cmd": "sudo docker exec -it onos_b bash -c '/root/onos/apache-karaf-4.2.6/bin/client app activate org.onosproject.openflow'", 
    "delta": "0:00:03.291473", 
    "end": "2020-01-23 20:00:33.229114", 
    "invocation": {
        "module_args": {
            "_raw_params": "sudo docker exec -it onos_b bash -c '/root/onos/apache-karaf-4.2.6/bin/client app activate org.onosproject.openflow'", 
            "_uses_shell": true, 
            "argv": null, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "stdin": null, 
            "stdin_add_newline": true, 
            "strip_empty_ends": true, 
            "warn": true
        }
    }, 
    "msg": "non-zero return code", 
    "rc": 1, 
    "start": "2020-01-23 20:00:29.937641", 
    "stderr": "", 
    "stderr_lines": [], 
    "stdout": "Logging in as karaf\r\nFailed to get the session.", 
    "stdout_lines": [
        "Logging in as karaf", 
        "Failed to get the session."
    ]
}

When I ssh to the sever running commands, shows

onos-b:~$ sudo docker exec -it onos_b bash -c '/root/onos/apache-karaf-4.2.6/bin/client app activate org.onosproject.fwd'
Logging in as karaf
Activated org.onosproject.fwd
Reply all
Reply to author
Forward
0 new messages