ansible

Centos7 docker-py doesn't seem to be installed

血红的双手。 提交于 2020-01-01 08:25:09
问题 I installed Centos7 minimal and then: ansible, docker, pip and using pip I installed docker-py. Versions: - Docker version 1.6.0, build 8aae715/1.6.0 - ansible 1.9.1 - docker_py-1.2.2 Trying to run a playbook, for example - name: redis container docker: name: myredis image: redis state: started i get msg: docker-py doesn't seem to be installed, but is required for the Ansible Docker module. I can't see the problem. Is it the CentOS, docker and ansible version? PS: I disabled the firewalld and

kubernetes 二进制部署ansible playbook 一键生成

独自空忆成欢 提交于 2020-01-01 07:19:57
脚本仓库地址 https://github.com/qist/k8s #支持 Ubuntu 18及以上的系统,CentOS7及CentOS8 系统 # k8s 版本 14,15,16,17 号版本 ansible 安装 #Ubuntu 系列安装 apt -y install ansible #CentOS 8 安装 dnf -y install ansible # CentOS 7 安装 yum -y install ansible # 修改ansible 配置 ## 说明id_rsa_storm1 私钥名字请自行修改 sed -i 's/^#private_key_file =.*$/private_key_file =\/root\/.ssh\/id_rsa_storm1/g' /etc/ansible/ansible.cfg sed -i 's/^#sudo_user = root/sudo_user = root/g' /etc/ansible/ansible.cfg sed -i 's/^#remote_port = 22/remote_port = 22/g' /etc/ansible/ansible.cfg sed -i 's/^#host_key_checking = False/host_key_checking = False/g' /etc/ansible

Running an Ansible Playbook using Python API 2.0.0.1

女生的网名这么多〃 提交于 2020-01-01 06:10:27
问题 Ansible version : 2.0.0.1 I've been looking around quite a bit now, and most documentation I find is either incomplete or deprecated (this post is for version 1.8.4, ie) I'm trying to launch an Ansible playbook through the Python API. Ansible's documentation seem to be showing how to generate and play tasks, but not how to load and run a playbook yml file. I've been digging into the code to try to understand how to launch it, and I think I've done some progress, but I'm really hitting a wall.

How to traverse a nested dict structure with Ansible?

人走茶凉 提交于 2020-01-01 05:38:28
问题 I have the following dict structure variable in an ansible playbook: apache_vhosts: - name: foo server_name: foo.com server_aliases: - a.foo.com - b.foo.com - c.foo.com - name: bar server_name: bar.com server_aliases: - d.bar.com - e.bar.com - f.bar.com I need to create a symlink for each of the server_name and server_aliases domains, e.g.: /tmp/foo.com -> /var/www/foo /tmp/a.foo.com -> /var/www/foo /tmp/b.foo.com -> /var/www/foo /tmp/c.foo.com -> /var/www/foo /tmp/bar.com -> /var/www/bar

Correct way to create dynamic lists in Ansible

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 04:52:06
问题 I'm looking for advice. I have the following code that creates a list dynamically that I can then later use in a template. This is a copy of the test code I put together - for the actual role I just added the admins|regex_replace variable into the j2 template. --- - hosts: localhost gather_facts: false vars: # define empty admins var first so ansible doesn't complain admins: admin_accounts: - name: john uid: 1000 group: sysadmin shell: /bin/bash comment: "Unix Administrator" - name: paul uid:

How to create a new partition with Ansible

。_饼干妹妹 提交于 2020-01-01 04:27:11
问题 When I run this on the command line it works fine: echo -e "n\np\n1\n\n\nw" | sudo fdisk /dev/sdb But in Ansible it does not want to run in shell: - name: partition new disk shell: echo -e "n\np\n1\n\n\nw" | sudo fdisk /dev/sdb It does not come back with an error, but it does not create the partition either. I checked that Ansible and LVM will not do what I need. Any advice? 回答1: By default, Ansible executes /bin/sh shell. For example, if /bin/sh is linked to dash , it's built echo is

default value for dictionary in jinja2 (ansible)

你离开我真会死。 提交于 2020-01-01 04:19:08
问题 jinja2 has filter '|default()' to works with undefined variables. But it does not work with dictionary values. if D may have or not have key foo (D[foo]), than: {{ D[foo]|default ('no foo') }} will prints 'no foo' if D is undefined, but will cause error ('dict object' has no attribute 'foo') if D is defined, but D[foo] is undefined. Is any way to make default for dictionary item? 回答1: This appears to be working properly for me using Ansible 1.7.2. Here's a test playbook I just wrote: --- -

Copy local file if exists, using ansible

老子叫甜甜 提交于 2020-01-01 03:55:06
问题 I'm working in a project, and we use ansible to create a deploy a cluster of servers. One of the tasks that I've to implement, is to copy a local file to the remote host, only if that file exists locally. Now I'm trying to solve this problem using this - hosts: 127.0.0.1 connection: local tasks: - name: copy local filetocopy.zip to remote if exists - shell: if [[ -f "../filetocopy.zip" ]]; then /bin/true; else /bin/false; fi; register: result - copy: src=../filetocopy.zip dest=/tmp/filetocopy

Ansible hangs when starting node.js server

て烟熏妆下的殇ゞ 提交于 2020-01-01 01:54:05
问题 I would like to start my node.js app in an ansible playbook. Right now, the final directive looks like this: - name: start node server shell: chdir=${app_path} npm start& The problem is that ansible never returns from this. How can I make it continue? 回答1: Forever seems to be the simplest and easiest way of starting and daemonizing Node.js apps. Currently, there's no Ansible module for forever, but you can still use the following plays to install forever and run your app: - name: "Install

How can I hide skipped tasks output in Ansible

孤者浪人 提交于 2020-01-01 01:28:16
问题 I have Ansible role, for example --- - name: Deploy app1 include: deploy-app1.yml when: 'deploy_project == "{{app1}}"' - name: Deploy app2 include: deploy-app2.yml when: 'deploy_project == "{{app2}}"' But I deploy only one app in one role call. When I deploy several apps, I call role several times. But every time there is a lot of skipped tasks output (from tasks which do not pass condition), which I do not want to see. How can I avoid it? 回答1: Ansible allows you to control its output by