小编Aje*_*han的帖子

通过ansible playbook从git克隆一个特定的分支

我正在使用ansible来部署我的应用程序.我正在使用以下内容从github克隆应用程序:

- name: Deploy site files from Github repository
  sudo: yes
  git: repo=git@github.com:xyz/abc.git dest=/home/{{deploy_user}}/{{app_name}} key_file=/home/ubuntu/.ssh/id_rsa accept_hostkey=yes force=yes
Run Code Online (Sandbox Code Playgroud)

我想从存储库中克隆一个特定的分支.我阅读了ansible的文档,但找不到克隆特定分支的任何选项.它可以选择克隆版本但不支持分支.

github ansible ansible-playbook

32
推荐指数
2
解决办法
3万
查看次数

暂停ansible playbook以进行用户确认,是否运行休息任务

我正在运行ansible-playbook其中列出了许多任务.所有这些都用来逐个运行,但我想pause在特定任务之后向剧本询问用户是否要继续运行其余任务或退出.我已经看到了pause moduleansible但是看不到任何询问用户是或否的示例,而这些示例依次继续或退出ansible-playbook.

ansible ansible-playbook

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

在ansible中部署时如何拉动

我正在使用Ansible进行配置管理,并使用以下任务来克隆Git 仓库:

# Example git checkout from Ansible Playbooks
- git: repo=git://foosball.example.org/path/to/repo.git
       dest=/srv/checkout
       version=release-0.22
Run Code Online (Sandbox Code Playgroud)

这将使用特定版本克隆repo.

git pull如果回购已经存在,它会在再次运行时执行吗?或者它只是一直克隆回购?git pull如果repo已经存在,如何在Ansible中执行a ,如果repo存在,我们如何运行特定命令,如果第一次克隆repo,我们如何运行?

git github ansible ansible-playbook

10
推荐指数
1
解决办法
1万
查看次数

不能用ansible来源〜/ .bashrc文件

我有一个文件中的别名列表.bash_aliases,正在被复制到远程服务器ansible playbook.该文件得到复制到目标,但.bashrc(这反过来加载.bash_aliases)文件是没有得到使用以下ansible任务加载.

我试过给出可执行参数

  - name: source the .bashrc file
    shell: source ~/.bashrc
    args:
      executables: "/bin/bash"
Run Code Online (Sandbox Code Playgroud)

没有争论

  - name: source the .bashrc file
    shell: source ~/.bashrc
Run Code Online (Sandbox Code Playgroud)

使用原始模块

  - name: source the .bashrc file
    raw: source ~/.bashrc
Run Code Online (Sandbox Code Playgroud)

使用命令模块 - 名称:源.bashrc文件命令:source~/.bashrc

什么都行不通!任何帮助

bash ansible

10
推荐指数
1
解决办法
7690
查看次数

IAM策略将用户限制为特定VPC中的实例

我试图IAM policy限制用户访问特定的所有实例VPC.遵循我的政策,但没有工作.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1450441260778",
            "Action": "ec2:*",
            "Effect": "Allow",
            "Resource": "arn:aws:ec2:region:Account_num:vpc/vpc-id"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

我已经填写相应account_numvpc-id政策英寸

amazon-web-services amazon-iam

9
推荐指数
1
解决办法
2363
查看次数

身份验证或权限失败,对远程目录没有权限

我正在使用ansijet自动化ansible playbook按钮点击运行.该手册将停止AWS上正在运行的实例.如果从命令行手动运行,则playbook运行良好并执行任务.但是当通过Web界面运行时ansijet,遇到以下错误

Authentication or permission failure.  In some cases, you may have been able to authenticate and did not have permissions on the remote directory. Consider changing the remote temp path in ansible.cfg to a path rooted in "/tmp". Failed command was: mkdir -p $HOME/.ansible/tmp/ansible-tmp-1390414200.76-192986604554742 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1390414200.76-192986604554742 && echo $HOME/.ansible/tmp/ansible-tmp-1390414200.76-192986604554742, exited with result 1:
Run Code Online (Sandbox Code Playgroud)

以下是ansible.cfg配置.

# some basic default values...

inventory      = /etc/ansible/hosts
#library        = /usr/share/my_modules/
remote_tmp     = $HOME/.ansible/tmp/
pattern        = * …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services ansible ansible-playbook

9
推荐指数
1
解决办法
5714
查看次数

通过docker-compose运行web rails g控制器生成的文件没有编辑权限

docker-compose用来为开发人员提供环境.应用程序在docker-compose build命令上正常运行并在0.0.0.0:3000on docker-compose up命令上运行.当我尝试运行命令docker-compose run web rails g controller以生成带有操作的控制器时,生成的文件比没有在主机上编辑的权限.

Dockerfile

FROM ubuntu:14.04
FROM ruby:2.2.1
# Run updates
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev

# Set up working directory
RUN mkdir /xyz/
WORKDIR /xyz/

# Set up gems
ADD Gemfile /xyz/Gemfile
ADD Gemfile.lock /xyz/Gemfile.lock

RUN bundle install

# Finally, add the rest of our app's code
# (this is done at the end so that changes to our …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails docker docker-compose

8
推荐指数
2
解决办法
1486
查看次数

ACL未在领事中启用

我在一个实例上设置了领事.在web-ui完美运行,但ACL未启用.以前我没有任何配置文件,但现在我已经创建了一个包含以下内容的config.json文件/etc/consul.d/bootstrap/.

{
    "bootstrap": true,
    "server": true,
    "datacenter": "dc1",
    "acl_datacenter": "dc1",
    "data_dir": "/var/consul",
    "encrypt": "consul keygen output",
    "ca_file": "/etc/consul.d/ssl/ca.cert",
    "cert_file": "/etc/consul.d/ssl/consul.cert",
    "key_file": "/etc/consul.d/ssl/consul.key",
    "verify_incoming": true,
    "verify_outgoing": true,
    "log_level": "INFO",
    "enable_syslog": true
}
Run Code Online (Sandbox Code Playgroud)

比我运行以下命令

consul agent -server -bootstrap -data-dir/tmp/consul -ui-dir/home/ubuntu/dist/-client = XXXX

这里X.X.X.X是我的实例的私有IP

但是ACL没有启用.

/etc/consul.d/server/config.json

{
    "bootstrap": false,
    "server": false,
    "log_level": "DEBUG",
    "enable_syslog": true,
    "datacenter": "dc1",
    "data_dir": "/var/consul",
    "ui_dir": "/home/ubuntu/dist",
    "acl_datacenter": "dc1"
    "encrypt": "SECRET"
}
Run Code Online (Sandbox Code Playgroud)

/etc/consul.d/server/config.json

{
    "bootstrap": false,
    "server": true,
    "log_level": "DEBUG",
    "enable_syslog": …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services consul

8
推荐指数
1
解决办法
2396
查看次数

使用ansible playbook启动已停止的AWS实例

我正在尝试在组下的文件中列出stop/start的特定group实例.以下playbook可以正常停止实例.hosts[target]

---
- hosts: target
  remote_user: ubuntu

  tasks:
  - name: Gather facts
    action: ec2_facts

  - name: Stop Instances
    local_action:
        module: ec2
        region: "{{region}}"
        instance_ids: "{{ansible_ec2_instance_id}}"
        state: stopped
Run Code Online (Sandbox Code Playgroud)

但是当我试图启动这些实例时,它不起作用,因为ec2_facts它无法ssh进入实例(因为它们现在被停止)并获得instance-ids

---
- hosts: target
  remote_user: ubuntu

  tasks:
  - name: start instances
    local_action:
        module: ec2
        region: "{{region}}"
        instance_ids: "{{ansible_ec2_instance_id}}"
        state: running
Run Code Online (Sandbox Code Playgroud)

我已经看过使用dynamic inventory主机文件的文档和硬编码的方法instance-ids.我想启动文件组IPs中列出的实例.targethosts

amazon-web-services ansible ansible-playbook

8
推荐指数
1
解决办法
1693
查看次数

如何管理造成停机的客运陈旧工人

我有一个在ubuntu 14.04机器上运行的rails应用程序,它由Nginx和服务passenger.有时候应用程序出现故障会发出以下错误

[ agents/LoggingAgent/Main.cpp:338 ]: Signal received. Gracefully shutting down... (send signal 2 more time(s) to force shutdown)
[ agents/LoggingAgent/Main.cpp:400 ]: Received command to shutdown gracefully. Waiting until all clients have disconnected...
[ ServerKit/Server.h:453 ]: [LoggerAdminServer] Shutdown finished
[ agents/LoggingAgent/Main.cpp:425 ]: PassengerAgent logger shutdown finished
[ ServerKit/Server.h:453 ]: [ServerThr.1] Shutdown finished
[ ServerKit/Server.h:453 ]: [ServerThr.2] Shutdown finished
[ ServerKit/Server.h:453 ]: [AdminServer] Shutdown finished
[ agents/HelperAgent/Main.cpp:724 ]: Disconnecting long-running connections for process 19431, application /public#default …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails passenger nginx ubuntu-14.04

8
推荐指数
1
解决办法
1224
查看次数