Ansible - 通过 Docker 安装 Check_MK

问题描述

我需要一些帮助。

我的任务是通过 Docker 通过 ansible 安装 check-mk (Nagios)。我设法安装了 docker,但我无法让它通过 ansible 安装 check-mk...

安装 check-mk 的命令是:

docker container run -dit -p 8080:5000 --ulimit nofile=1024 --tmpfs /opt/omd/sites/cmk/tmp:uid=1000,gid=1000 -v monitoring:/omd/sites --name monitoring -v /etc/localtime:/etc/localtime:ro --restart always checkmk/check-mk-raw:1.6.0-latest

到目前为止我的代码是这样的:

    - name: Install docker on a Centos 7 machine
      hosts: localhost
      vars:
        create_containers: 1
        default_container_name: docker
        default_container_image: centos
        default_container_command: sleep 1d
        
    tasks:
        - name: Add Docker CE repo
          get_url_
           url: https://download.docker.com/linux/centos/docker-ce.repo
           dest: /etc/yum.repos.d/docker-ce.repo
         
        - name: Install Docker
          yum: name=docker state=latest
          
        - name: Start and enable the Docker daemon
          service: name=docker state=started enabled=yes
          
        - name: Install Docker Module for Python
          pip:
            name: docker
            
        - name: Create a default container
          docker_container:
             name: "{{ default_container_name }}{{ item }}"
             image: "{{ default_container_image }}"
             command: "{{ default_container_command }}"
             state: present
          with_sequence: count={{ create_containers }}
          
          - name: Start a container with a command
            docker_container:
                name: docker1
                image: centos
                command: ["docker container run -dit -p 8080:5000 --ulimit nofile=1024 --tmpfs /opt/omd/sites/cmk/tmp:uid=1000,gid=1000 -v monitoring:/omd/sites --name monitoring -v /etc/localtime:/etc/localtime:ro --restart always checkmk/check-mk-raw:1.6.0-latest"]

但是它在启动我的 docker 容器时抛出错误

致命:[本地主机]:失败! => {“已更改”:false,“msg”:“启动容器 fd44b8066dd4d205a1b2883 时出错...:http+docker://localhost/v1.26/containers fd44b8066dd4d 的 404 客户端错误.../start:未找到(” oci 运行时错误:container_linux.go:235:启动容器进程导致"exec:\"/bin/docker\": stat /bin/docker: no such file or directory"\n")"}

谁能告诉我我做错了什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)