在这个官方文档中,它可以在yaml配置文件中运行命令:
http://kubernetes.io/v1.1/docs/user-guide/configuring-containers.html
apiVersion: v1
kind: Pod
metadata:
name: hello-world
spec: # specification of the pod’s contents
restartPolicy: Never
containers:
- name: hello
image: "ubuntu:14.04"
env:
- name: MESSAGE
value: "hello world"
command: ["/bin/sh","-c"]
args: ["/bin/echo \"${MESSAGE}\""]
Run Code Online (Sandbox Code Playgroud)
如果我想运行多个命令,该怎么办?
我在 Ansible 2 中获取匹配的正则表达式模式时遇到问题。有人可以帮助我理解我做错了什么吗?谢谢。
--- # Disable auto update for Ubuntu
- hosts: nonedgeLinux
become: yes
tasks:
- name: disable auto updates
replace:
dest: /etc/apt/apt.conf.d/50unattended-upgrades
regexp: '(?:[ \t]*\"\${distro_id}:\${distro_codename}-security\";)'
replace: '// "\${distro_id}:\${distro_codename}-security\";'
Run Code Online (Sandbox Code Playgroud)
我使用https://regex101.com/根据正在搜索的文件内容的复制/粘贴来验证正则表达式。此测试报告正则表达式模式是正确的。每次在 Ubuntu 16.04.2 机器上运行时,我都会得到以下结果:
root@sbx54:/data/scripts/ansible# ansible-playbook disableAutoUpdate.yml -vvvv
Using /data/scripts/ansible/ansible.cfg as config file
Loaded callback default of type stdout, v2.0
1 plays in disableAutoUpdate.yml
PLAY ****************************************************************************
TASK [setup] *******************************************************************
ESTABLISH LOCAL CONNECTION FOR USER: root
localhost EXEC ( umask 22 && mkdir -p "$( echo $HOME/.ansible/tmp/ansible-tmp-1492480514.73-9504514182168 )" …Run Code Online (Sandbox Code Playgroud)