我有一个configMap从文件创建:
kubectl create configmap ssportal-apache-conf --from-file=ssportal.conf=ssportal.conf
Run Code Online (Sandbox Code Playgroud)
然后我需要将此文件挂载到部署中:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: ssportal
spec:
replicas: 2
template:
metadata:
labels:
app: ssportal
spec:
containers:
- name: ssportal
image: eu.gcr.io/my-project/ssportal:0.0.0
ports:
- containerPort: 80
volumeMounts:
- name: apache2-config-volume
mountPath: /etc/apache2/
volumes:
- name: apache2-config-volume
configMap:
name: ssportal-apache-conf
items:
- key: ssportal.conf
path: sites-enabled/ssportal.conf
Run Code Online (Sandbox Code Playgroud)
但这有效地/etc/apache2/从容器中删除了现有目录,并用一个唯一的文件替换它/etc/apache2/sites-enabled/ssportal.conf.
是否可以在现有配置目录上仅覆盖一个文件?
我有一个 10TB 存储桶,需要尽快创建它的副本。这样做的最快和最有效的方法是什么?
我只有在定义时才需要传递ssl_ca给mysql_db模块mysql_use_ssl.这是否可以使用一个任务,例如:
mysql_db: name=mydb state=import target=/tmp/mysql.sql login_host="mydbhost" login_user="root" login_password="password" {% if mysql_use_ssl %}ssl_ca=/path/to/cert.pem{% endif %}
Run Code Online (Sandbox Code Playgroud)
?
这个实际的片段不起作用,结果:
{"failed": true, "msg": "template error while templating string: Encountered unknown tag 'endif'.. String: /path/to/cert.pem{% endif %}"}
Run Code Online (Sandbox Code Playgroud)
移动条件时:
mysql_db: name=mydb state=import target=/tmp/mysql.sql login_host="mydbhost" login_user="root" login_password="password" ssl_ca="{% if mysql_use_ssl %}/path/to/cert.pem{% else %}none{% endif %}"
Run Code Online (Sandbox Code Playgroud)
然后它"工作"但none不支持关闭mysql ssl连接的参数,因此它不会关闭ssl.
我需要安装特定的软件包版本,但它不适用于 APT:
root@myhost:~# apt-get install my-lib-java=2016.03.30-79
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
my-lib-java
0 upgraded, 0 newly installed, 0 to remove and 93 not upgraded.
Run Code Online (Sandbox Code Playgroud)
旧版本已安装:
root@myhost:~# dpkg -l | grep my-lib-java
ii my-lib-java 2016.02.25-3-g5aa415e-75 amd64 no description given
Run Code Online (Sandbox Code Playgroud)
但我明确指定的版本确实存在:
root@myhost:~# apt-cache madison my-lib-java
my-lib-java | 2016.04.19-86 | https://my.re.po/dl/ubuntu/ trusty/ Packages
my-lib-java | 2016.03.30-79 | https://my.re.po/dl/ubuntu/ trusty/ Packages
my-lib-java | 2016.02.25-73 | https://my.re.po/dl/ubuntu/ trusty/ Packages
Run Code Online (Sandbox Code Playgroud)
如何安装2016.03.30-79?
我在一个主机上安装了新的Kubernetes 1.6.2 master,现在尝试使用https://github.com/coreos/flannel/blob/master/Documentation/kube-flannel.yml启动Flannel
吊舱没出现:
$ kubectl get pods kube-flannel-ds-l6gn4 --namespace kube-system
NAME READY STATUS RESTARTS AGE
kube-flannel-ds-l6gn4 1/2 CrashLoopBackOff 36 2h
$ kubectl logs kube-flannel-ds-l6gn4 --namespace kube-system kube-flannel
E0427 15:35:52.232093 1 main.go:127] Failed to create
SubnetManager: error retrieving pod spec for 'kube-system/kube-flannel-ds-l6gn4': the server does not allow access to the requested resource (get pods kube-flannel-ds-l6gn4)
Run Code Online (Sandbox Code Playgroud)
我也尝试使用默认的serviceaccount,但它不会出现.
我正在尝试修改 cookie 有效的域mod_headers:
从:
ipa_session=e88331a44e20d8b5caaacb0e896029fe; Domain=internal.example.com; Path=/ipa; Expires=Tue, 13 Dec 2016 09:31:33 GMT; Secure; HttpOnly
到:ipa_session=e88331a44e20d8b5caaacb0e896029fe; Domain=example.com; Path=/ipa; Expires=Tue, 13 Dec 2016 09:31:33 GMT; Secure; HttpOnly
Mod-headers 运行良好,这些规则有效:
Header set "something" "something"
Header edit "something" "something" "somethingdifferent"
Run Code Online (Sandbox Code Playgroud)
但编辑“Set-Cookie”标头什么也不做:
Header edit "Set-Cookie" "Domain=internal.example.com" "Domain=example.com"
Run Code Online (Sandbox Code Playgroud)
Apache 语法没问题,但规则什么也没做。
Apache软件包版本:2.4.18-2ubuntu3.1
我有一个非常简单的剧本:
- hosts: test
gather_facts: no
tasks:
- name: debug
debug: msg="{{ inventory_hostname }}"
run_once: yes
delegate_to: "host2"
Run Code Online (Sandbox Code Playgroud)
和库存文件:
host1 ansible_ssh_host="1.2.3.4"
host2 ansible_ssh_host="1.2.3.5"
[test]
host1
host2
Run Code Online (Sandbox Code Playgroud)
以及玩的结果:
TASK [debug] *************************************************************************************************************************************************************************
ok: [host1 -> host2] => {
"changed": false,
"msg": "host1"
}
Run Code Online (Sandbox Code Playgroud)
为了完整起见,无论我添加什么delegate_to,即使是一些随机字符串,结果总是"msg": "host1"。
如何正确将此任务委托给 groups.test.1 或任何其他主机?
编辑:
- hosts: test
gather_facts: no
tasks:
- name: 1
shell: "hostname -f"
run_once: yes
delegate_to: "host2"
register: result
- name: debug
debug: msg="{{ ansible_host }} {{ inventory_hostname }} {{ …Run Code Online (Sandbox Code Playgroud) 我有两个清单:
a:
- 1
- 2
- 3
b:
- 2
- 3
- 4
Run Code Online (Sandbox Code Playgroud)
a仅当 中包含任何项目时,我才需要运行任务b。这怎么可能?
tasks:
- name: one of elements of a in b
debug: msg=At least one of elements of a is contained in b
when: ???
Run Code Online (Sandbox Code Playgroud)