小编cru*_*der的帖子

如何在docker swarm中重启多个容器

我目前在docker设置中有4个不同主机的8个容器.

ubuntu@ip-192-168-1-8:~$ docker service ls
ID            NAME         MODE    REPLICAS  IMAGE
yyyytxxxxx8  mycontainers  global  8/8     myapplications:latest
Run Code Online (Sandbox Code Playgroud)

运行ps -a服务会产生以下结果.

ubuntu@ip-192-168-1-8:~$ docker service ps -a yy
NAME                            IMAGE                        NODE          DESIRED STATE  CURRENT STATE        ERROR  PORTS
 mycontainers1                myapplications:latest:   ip-192-168-1-5 Running        Running 3 hours ago
 \_ mycontainers2                myapplications:latest: ip-192-168-1-6  Running        Running 3 hours ago
 \_ mycontainers3                myapplications:latest:  ip-192-168-1-7  Running        Running 3 hours ago
\_ mycontainers4                myapplications:latest:  ip-192-168-1-8  Running        Running 3 hours ago
\_ mycontainers1                myapplications:latest: ip-192-168-1-5  Running        Running 3 hours ago
 \_ mycontainers2 …
Run Code Online (Sandbox Code Playgroud)

docker docker-swarm

6
推荐指数
2
解决办法
7964
查看次数

Mesos无法将错误连接到IP:5050

我是Mesos的新手,刚刚在我的测试服务器上设置了mesos和zookeeper.

不幸的是,我一直在我的mesos控制台上收到此错误消息,表明我无法连接到端口5050上的mesos,似乎无法找出原因.

我在下面的屏幕截图中包含了错误

mesos日志文件未指出错误显示的原因.

在此输入图像描述

apache mesos mesosphere apache-zookeeper

5
推荐指数
2
解决办法
5397
查看次数

在ansible中提取最后两个IP

我需要一些帮助,想出一种非常简单的方法来从 ansible 的 IP 地址中提取最后两个数字。我的剧本目前看起来像这样

---
- hosts: localhost
  tasks:
   - name: install dns resolver
     yum: name=python-dns

   - debug: msg={{ lookup('dig','google.com.') }}
Run Code Online (Sandbox Code Playgroud)

运行这个剧本会产生以下结果

TASK [install dns resolver] ****************************************************
ok: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "172.217.7.142"
Run Code Online (Sandbox Code Playgroud)

有没有办法只返回该IP的最后两个数字?ie42

实际上,我必须将其嵌入到最终将具有如下格式的模板中:

last_two_numbers_of_IP={{ lookup('dig','google.com.') }}
Run Code Online (Sandbox Code Playgroud)

模板中的输出应如下所示:

 last_two_numbers_of_IP=42
Run Code Online (Sandbox Code Playgroud)

python ansible

3
推荐指数
1
解决办法
3331
查看次数

在多个目录下恢复Selinux文件上下文

我目前正在使用sefcontext模块来管理服务器SeLinux文件上下文

以下是用于管理某些目录的任务示例。

name: Set selinux policy for directories
sefcontext:
 target: '{{ item.target }}(/.*)?'
 setype: "{{ item.setype }}"
 reload: True
 register: "{{item.register}}"
 state: present
with_items:
- { target: '/var/lib/dir1', setype: 'public_content_rw_t', register: 'dir1' }
- { target: '/var/lib/dir2', setype: 'public_content_rw_t', register: 'dir2' }
Run Code Online (Sandbox Code Playgroud)

我现在遇到的问题是,执行此类操作无法恢复文件标签,也无法实现幂等

name: Run restore context to reload selinux
shell: restorecon -Rv /var/lib/{{ item.shell }}
when: "{{ item.when }}"
with_items:
- { shell: 'dir1', when: 'dir1|changed' }
- { shell: 'dir2', when: 'dir2|changed' }
Run Code Online (Sandbox Code Playgroud)

知道如何在保持幂等的同时还原多个目录上的文件标签吗?

yaml ansible

3
推荐指数
1
解决办法
2852
查看次数

如何在 Groovy 中检查方法是否返回非零退出代码

我有一个 Jenkinsfile 项目,它要求我包含一个'if statement来确定某些方法中的 shell 命令是否返回0.

第一种方法method 1按预期工作。但是,我想包含一个if statement跳过第二阶段的内容,因为该 shell 命令method 2不会以0.

def method1(setup){
  sh """
  echo ${setup}
  """
}
def method2(setup){
  sh """
   ech ${setup}
  """
}
node {
  stage('print method1'){   
    method1('paul')
  }
// I need an if statement to skip this method since the if statement returns non=zero

  stage('This method should be skipped'){   
   if(method2 returns != 0) //This if condition fails but need something similar to …
Run Code Online (Sandbox Code Playgroud)

groovy jenkins-pipeline

2
推荐指数
1
解决办法
2328
查看次数