在Debian 7.3上我通过ansible playbook安装了nginx,mysql,php-fpm.
通常,在安装PHPMyAdmin时
aptitiude install phpmyadmin
Run Code Online (Sandbox Code Playgroud)
它需要数据库密码,并进行一些配置.
现在创建一个播放来安装和配置PHPMyAdmin由ansible我应该怎么做?
我写了一个安装phpmyadmin的游戏.在安装过程中,它需要数据库用户名,密码和自己的帐户.所以在搜索后我发现,有一个模块在ansible中命名为debconf它可以处理一些安装过程的问题.像这样:
tasks:
- name: debconf for pma
debconf: name=phpmyadmin question='phpmyadmin/dbconfig-install' value='true' vtype='boolean'
- name: debconf for pma
debconf: name=phpmyadmin question='phpmyadmin/app-password-confirm' value='{{mysql_root_pass}}' vtype='password'
- name: debconf for pma
debconf: name=phpmyadmin question='phpmyadmin/mysql/admin-pass' value='{{mysql_root_pass}}' vtype='password'
- name: debconf for pma
debconf: name=phpmyadmin question='phpmyadmin/mysql/app-pass' value='{{mysql_root_pass}}' vtype='password'
- name: debconf for pma
debconf: name=phpmyadmin question='phpmyadmin/reconfigure-webserver' value='' vtype='multiselect'
- name: install pma
apt: pkg=phpmyadmin state=present
- name: configure site
file: path=/var/www/pma src=/usr/share/phpmyadmin state=link
Run Code Online (Sandbox Code Playgroud)
现在我想了解更多关于它的信息?关于安装和配置过程,?
我正在使用ec2.py动态库存来配置ansible.我放置了ec2.py在/etc/ansible/hosts文件和可执行其标记.我也有ec2.ini文件/etc/ansible/hosts.
[ec2]
regions = us-west-2
regions_exclude = us-gov-west-1,cn-north-1
destination_variable = public_dns_name
vpc_destination_variable = ip_address
route53 = False
all_instances = True
all_rds_instances = False
cache_path = ~/.ansible/tmp
cache_max_age = 0
nested_groups = False
group_by_instance_id = True
group_by_region = True
group_by_availability_zone = True
group_by_ami_id = True
group_by_instance_type = True
group_by_key_pair = True
group_by_vpc_id = True
group_by_security_group = True
group_by_tag_keys = True
group_by_tag_none = True
group_by_route53_names = True
group_by_rds_engine = True
group_by_rds_parameter_group = …Run Code Online (Sandbox Code Playgroud) amazon-ec2 amazon-web-services ansible ansible-playbook ansible-inventory
是否可以基于元数据变量和值来定位具有Ansible的谷歌计算实例,即当它们具有值为site1的网站名称的元数据变量时,将此剧本应用于标记为Web的项目服务器?
我只是使用Ansible提供的示例通过剧本学习Ansible。 https://github.com/ansible/ansible-examples/tree/master/lamp_simple
当我尝试在剧本的开头放置调试消息时,出现以下错误。
vagrant@packer-debian-7:~/ansible-examples-master/lamp_simple$ ansible-playbook -i hosts site.yml --private-key=~/.ssh/google_compute_engine -vvvv
ERROR: debug is not a legal parameter at this level in an Ansible Playbook
Run Code Online (Sandbox Code Playgroud)
[site.yml]
---
# This playbook deploys the whole application stack in this site.
- debug: msg="Start KickAsssss"
- name: apply common configuration to all nodes
hosts: all
roles:
- common
- name: configure and deploy the webservers and application code
hosts: webservers
roles:
- web
- name: deploy MySQL and configure the databases
hosts: dbservers
roles: …Run Code Online (Sandbox Code Playgroud) 我正在尝试这个YML代码:
- name: Check links
file: name=/usr/local/bin/zsh state=link
Run Code Online (Sandbox Code Playgroud)
但是它总是以失败告诉我:src and dest are required for creating links.我要做的只是检查链接路径是否存在.如果不存在,我不打算创建它.
有没有Ansible-idiomatic方法来做到这一点?
我试图在Ansible回放循环中将变量连接到自身,但我无法做到.可能是它的简单但无法实现这一点.
我在这里尝试的是什么
- name: all directories
set_fact: all_dir={{ item }}
with_items:
- src/main/java
- src/main/test
- src/main/resources
- debug: var=all_dir
Run Code Online (Sandbox Code Playgroud)
all_dir中的预期输出
src/main/java src/main/test src/main/resources
Run Code Online (Sandbox Code Playgroud)
我试过加入.有什么建议吗?
我正在尝试从第二个剧本中我的剧本中的第一个"播放"中访问名为"count"的变量.我在这里发现了一些关于同一问题的其他帖子,我认为我正在遵循正确的步骤,但下面的代码仍然失败.
代码
- hosts: group1
tasks:
- name: count registrations on primary node
shell: psql -U widgets widgets -c 'SELECT COUNT(*) FROM location' -t
register: count
- debug: var=count.stdout
- hosts: group2
tasks:
#the line below works...
# - debug: msg={{ hostvars['myserver1.mydomain.com']['count']['stdout'] }}
# but this one fails
- debug: msg={{ hostvars['group1']['count']['stdout'] }}
Run Code Online (Sandbox Code Playgroud)
这会产生以下输出:
PLAY ***************************************************************************
TASK [setup] *******************************************************************
ok: [myserver1.mydomain.com]
TASK [count registrations on node] **************************************
changed: [myserver1.mydomain.com]
TASK [debug] *******************************************************************
ok: [myserver1.mydomain.com] => {
"count.stdout": " 2"
} …Run Code Online (Sandbox Code Playgroud) 我们正在使用ansible将多个节点配置为一个集群。这些机器是在自定义AWS类似基础设施上创建的实例。我们在不同的剧本上有大约一百个任务,它们在每个节点上执行。
问题是,我们收到零星的主机无法访问的错误,并且由于以下失败而停止了剧本的执行:
TASK [common : install basic packages] *************************
fatal: [fqdn.for.a.node]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}
Run Code Online (Sandbox Code Playgroud)
用-vvv输出:
TASK [common : install basic packages] *******************************
task path: /jenkins/workspace/Cluster-Deployment/91/roles/common/tasks/install-basic-packages.yml:1
<fqdn.for.a.node> ESTABLISH SSH CONNECTION FOR USER: root
<fqdn.for.a.node> SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile="id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=600 -o ControlPath=/home/turkenh/.ansible/cp/ansible-ssh-%h-%p-%r fqdn.for.a.node '/bin/sh -c '"'"'( umask 77 && mkdir -p "` …Run Code Online (Sandbox Code Playgroud) openssh amazon-web-services ansible ansible-playbook ansible-2.x
所以我注意到在我的ansible playbooks中,如果我使用相同的playbook定位多个主机,那么每个任务必须在所有主机进入下一个任务之前完成.
是否可以定义播放簿,以便任务在完成后立即运行以下任务而无需等待任务在所有其他主机上完成?
我在playbook.yml中添加了一个名为common的角色,并且配置失败并显示以下消息:
TASK [common : Host is present] ************************************************
==> cd: fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'unicode object' has no attribute 'host_ip'\n\nThe error appears to have been in '/vagrant/ansible/roles/common/tasks/main.yml': line 7, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Host is present\n ^ here\n"}
Run Code Online (Sandbox Code Playgroud)
这是roles/common/tasks/main.yml失败的特定任务的内容
- …Run Code Online (Sandbox Code Playgroud) configuration provisioning configuration-management ansible ansible-playbook
ansible-playbook ×10
ansible ×9
amazon-ec2 ×1
ansible-2.x ×1
debian ×1
installation ×1
jinja2 ×1
openssh ×1
phpmyadmin ×1
provisioning ×1
wait ×1