我想创建一个带有打包器和ansible的aws windows AMI.
我已经尝试了很多配置,但我仍然存在与实例连接的问题.
这是我的包装工conf:
{
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "eu-west-1",
"source_ami": "ami-58a1a73e",
"instance_type": "m3.medium",
"ami_name": "aaa-windows-ami {{timestamp}}",
"user_data_file":"./test.ps",
"communicator": "winrm",
"winrm_username": "Administrator",
"winrm_use_ssl": true,
"winrm_insecure": true
}],
"provisioners": [
{
"type": "ansible",
"playbook_file": "./playbook.yml",
"extra_arguments": [
"--extra-vars", "ansible_user=Administrator ansible_connection=winrm ansible_ssh_port=5986 ansible_winrm_server_cert_validation=ignore ansible_shell_type=powershell ansible_shell_executable=None"
]
},
{
"type": "powershell",
"script": "./init.ps1"
}
]
}
Run Code Online (Sandbox Code Playgroud)
用户数据脚本正在AWS实例上激活winrm.
<powershell>
write-output "Running User Data Script"
write-host "(host) Running User Data Script"
Set-ExecutionPolicy Unrestricted -Scope LocalMachine -Force -ErrorAction …Run Code Online (Sandbox Code Playgroud) 我必须配置多个https网站,每个网站都有一个专用证书.它工作得很好.
server {
listen 443;
server_name client1.localhost.eu;
ssl on;
ssl_certificate ...;
ssl_certificate_key ...;
root /var/www/client1;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm-client1.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
server {
listen 443;
server_name client2.localhost.eu;
ssl on;
ssl_certificate ...;
ssl_certificate_key ...;
root /var/www/client2;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm-client2.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我想将"位置"块分解,因为它始终是相同的.可能吗 ?(我也试过只在服务器块上,但是不可能在ssl属性中放置一个变量)
非常感谢你的帮助.
埃里克
我正在使用 AWS Cloudwatch 日志代理。它工作得很好,很好。我有一个这样的配置:
[type1]
datetime_format = %Y-%m-%d %H:%M:%S
file = /var/log/payment_type1.log
buffer_duration = 5000
log_stream_name = payment
initial_position = start_of_file
log_group_name = type1
[type2]
datetime_format = %Y-%m-%d %H:%M:%S
file = /var/log/payment_type2.log
buffer_duration = 5000
log_stream_name = payment
initial_position = start_of_file
log_group_name = type2
Run Code Online (Sandbox Code Playgroud)
每种付款方式都有一个部分。是否可以将所有这些部分合二为一?并在 log_group_name 标签中添加一个变量。例如类似的东西?
[type]
datetime_format = %Y-%m-%d %H:%M:%S
file = /var/log/payment_(<my_type>.*).log
buffer_duration = 5000
log_stream_name = payment
initial_position = start_of_file
log_group_name = my_type
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助。
埃里克
我创建了一个功能,可以使用页面创建者的语言发布新闻。
这是创建新闻的代码:
def add_news
locale = creator.language.blank? ? I18n.locale : creator.language
I18n.with_locale(locale) do
title = I18n.t('news.subject')
end
create_news({title: title})
end
Run Code Online (Sandbox Code Playgroud)
它运作良好,新闻是用好的语言创造的。但有时,使用了错误的语言。我已经阅读了 i18n ( https://github.com/svenfuchs/i18n/blob/master/lib/i18n.rb )的源代码,对我来说with_local函数不是线程安全的。我很惊讶,因为我没有读过关于这个问题的帖子。
那么,你觉得呢?线程安全与否?如果是这样,您知道其他解决方案吗?
谢谢和 br,
埃里克
我有一个与其他团队共享的部署项目。我已使用保险库加密了我的秘密。我想使用密码对生产文件进行加密,并使用其他密码对登台文件进行加密,以避免其他团队访问生产机密。
有可能这样做吗?
我已经做了类似的事情。我的秘密:
cat /group_vars/all/vault_production.yml (encrypt with password A)
production_password: 'test1'
cat/group_vars/all/vault_staging.yml (encrypt with password B)
staging_password: 'test2'
Run Code Online (Sandbox Code Playgroud)
我的环境:
cat hosts-production
[all:vars]
env_type=production
cat hosts-staging
[all:vars]
env_type=staging
Run Code Online (Sandbox Code Playgroud)
我的剧本:
- copy:
content: |
env PASS={{hostvars[inventory_hostname][env_type + '_password']}}
...
Run Code Online (Sandbox Code Playgroud)
然后我像这样启动剧本。
# for production
ansible-playbook -i hosts-staging test.yml --vault-password-file .password_a
# for staging
ansible-playbook -i hosts-staging test.yml --vault-password-file .password_b
Run Code Online (Sandbox Code Playgroud)
但这不起作用,因为有两个不同的密码(错误!解密失败)。你知道怎么做吗 ?
谢谢。
BR
埃里克
我想使用正则表达式(并且仅限正则表达式)排除目录中的“.txt”文件。但这段代码不起作用,我不明白为什么。我有这个清单:
['/var/tmp/COMMUN/4.1.0_41/Apache',
'/var/tmp/COMMUN/4.1.0_41/META-INF',
'/var/tmp/COMMUN/4.1.0_41/RewriteRules',
'/var/tmp/COMMUN/4.1.0_41/Robots',
'/var/tmp/COMMUN/4.1.0_41/smokeTest',
'/var/tmp/COMMUN/4.1.0_41/tutu.txt']
Run Code Online (Sandbox Code Playgroud)
我正在尝试这段代码
# list_dit is a personal function
list_dir(toto, filter_function=lambda x: re.match("^.*(?!txt)$", x))
Run Code Online (Sandbox Code Playgroud)
有人看一下出了什么问题吗?
我需要在Apache的日志中对IP应用掩码。
例如,我有这个日志:192.168.234.111 - - [18/Oct/2013:16:29:40 +0200]“GET ........”
我想保存:192.168.234.xxx - - [18/Oct/2013:16:29:40 +0200]“GET ......”
为了做第一个日志,我使用这样的日志格式。
LogFormat "%h %l %u %t" combined-syslog2
CustomLog /var/log/toto combined-syslog2
Run Code Online (Sandbox Code Playgroud)
要获得第二个日志,我可以通过管道传输这样的 perl/shell post 脚本:
CustomLog |/usr/local/shl/apache_syslog2
Run Code Online (Sandbox Code Playgroud)
但我对这个解决方案并不满意。可以用 Apache 做到这一点吗?
谢谢。
埃里克
我有这样的剧本,每个客户有一个角色.
- hosts: hosting
roles:
- { role: client1, tags: ['client1'] }
- { role: client2, tags: ['client2'] }
Run Code Online (Sandbox Code Playgroud)
在每个角色上,我都依赖于nginx.
/roles/client1/meta/main.yml
dependencies:
- nginx
Run Code Online (Sandbox Code Playgroud)
我不希望在没有必要时启动 nginx角色.所以我已经将nginx标签添加到依赖项中.
/roles/client1/meta/main.yml
dependencies:
- { role: nginx, tags: ['system'] }
Run Code Online (Sandbox Code Playgroud)
但是当我使用标签client1启动playbook时,会执行nginx角色.有避免这种情况的解决方案吗?
我知道可以"导出"对剧本的依赖,它运作良好,但我认为这不是一个好的解决方案.
- hosts: hosting
roles:
- { role: nginx, tags: ['system'] }
- { role: client1, tags: ['client1'] }
- { role: client2, tags: ['client2'] }
Run Code Online (Sandbox Code Playgroud) 我的debian vm上有一个奇怪的问题.
我有一个这样的nginx目录.
$ ll
total 9076
-rw-r----- 1 www-data adm 330645 juil. 13 10:40 access.log
-rw-r--r-- 1 www-data root 143902 juil. 12 01:08 access.log.1
-rw-r----- 1 www-data adm 852976 juil. 13 10:41 error.log
Run Code Online (Sandbox Code Playgroud)
我尝试用foo用户读取access.log .所以,我已将此用户添加到adm组.
$ cat /etc/group | grep adm
adm:x:4:admin,foo
Run Code Online (Sandbox Code Playgroud)
但是用户无法读取文件.我试图将用户添加到www-data组,但问题是一样的.你知道这是什么问题吗?我想知道用户/组如何工作,似乎不是:)
BR,
埃里克