ansible

import an variable file to another in ansible

假装没事ソ 提交于 2020-01-24 20:20:13
问题 I am new to ansible. I have 2 variable files one is global and another is environment specific. Here is the global one in global/group_var/all.yaml folder: rel: deployment: webui: dockerName: "rel" dockerTag: "Dev_{{ travis.build_number }}" And the specific one is in develop/group_var/all.yaml folder docker: registery: "xxxx" is there any way I can import global/group_var/all.yaml to develop/group_var/all.yaml import global/group_var/all.yaml docker: registery: "xxxx" so develop/group_var/all

To deploy Play Framework apps in AWS (Amazon) ec2 using Ansible playbook

荒凉一梦 提交于 2020-01-24 20:15:12
问题 I am very new to AWS ec2 platform. I wanted to deploy my play 2.* app in the ec2. Also I need to deploy it through git in future update. I have done a decent research on it and found Ansible playbook could be a better solution to this. But I am using windows and configured it with ec2 using putty. Now I know very less about command line programming and Ansible and Ansible playbook . I need some help to find the solution for play to run in ec2 throug git directly. I am sharing some interesting

How do you get group name of the executing role in ansible [duplicate]

帅比萌擦擦* 提交于 2020-01-24 05:50:09
问题 This question already has answers here : How to list groups that host is member of? (3 answers) Closed 2 years ago . I have a use case where I need to create a directory in all hosts in a group whose name will be the name of the group. Eg : I create a dynamic inventory file with output of the form : { "db": ["host1", "host2", "host3"], "logs": ["host2"], "misc": ["host4"] } I need to create a directory by the name db in every host of the group db and directory named log in every host of the

Copy folder content with Ansible

橙三吉。 提交于 2020-01-24 05:29:05
问题 For some weird reasons I'm having troubles with a simple task which is copying a content of the folder myfiles (few files in there) to the dist/myfiles location. Task looks like this: name: Deploy config files like there is no tomorrow copy: src: "{{ item }}" dest: "/home/{{ ansible_user_id }}/dist/{{ item }}" with_items: - 'config' - 'myfiles/' myfiles folder exist under the dist and config file is copied to the dist folder. Is this possible in Ansible or I should copy each file separately?

Don't mark something as changed when determining the value of a variable

℡╲_俬逩灬. 提交于 2020-01-24 02:18:58
问题 I have the following role in my Ansible playbook to determine the installed version of Packer and conditionally install it if it doesn't match the version of a local variable: --- # detect packer version - name: determine packer version shell: /usr/local/bin/packer -v || true register: packer_installed_version - name: install packer cli tools unarchive: src: https://releases.hashicorp.com/packer/{{ packer_version }}/packer_{{ packer_version }}_linux_amd64.zip dest: /usr/local/bin copy: no

How to convert a string with key value pairs into a list of dictionaries?

爱⌒轻易说出口 提交于 2020-01-23 18:16:07
问题 I am trying to migrate my playbooks into ansible tower environment. In my playbook, I defined variables like db_list: db_list: - { dbid: 1, dbname: abc} - { dbid: 2, dbname: xyz} in tower survey, I can put similar info as textarea in survey: dbid: 1, dbname: abc dbid: 2, dbname: xyz How can I convert my textarea data into a list of dictionary? I can't find any suitable jinj2 filter for conversion. my ansible version is 2.4. 回答1: Assuming the contents of the textarea are in a variable called

openshift3.10集群部署

谁说我不能喝 提交于 2020-01-23 16:25:52
简介 openshift是基于k8s的开源容器云。 要求 系统环境:CentOS 7.5 搭建一个master节点,两个node节点 注意: openshift3 依赖docker的版本为1.13.1 openshift3.10支持的是ansible2.4.3.0以上2.8.X以下 保证各节点时间统一,可以统一向阿里云时间服务器同步 准备工作 所有节点创建工作目录:在根目录下创建家目录 mkdir /home && cd /home # 先关闭防火墙,后续为了安全再重新配置防火墙 # 查看防火墙的状态 systemctl status firewalld # 关闭防火墙 systemctl stop firewalld # 关闭防火墙的自启动 systemctl disable firewalld 配置说明 修改主机名 #master: #192.168.2.180 hostnamectl set-hostname master.example.com #node1: #192.168.2.181 hostnamectl set-hostname node1.example.com #node2: #192.168.2.182 hostnamectl set-hostname node2.example.com 域名映射 这3台主机(master,node1,node2)都需要在

Centos 7.6 Install ansible-playbook install docker simple

℡╲_俬逩灬. 提交于 2020-01-23 14:05:29
安装ansible yum install ansible vim wget net-tools git -y 添加主机 vim /etc/ansible/hosts [docker-install] 192.168.3.209 hostname=docker ansible_ssh_port=22 ansible_ssh_user=root ansible_ssh_pass=1234.com 下载docker,pigz到目录 mkdir -p /etc/ansible/roles/docker && wget -N -P /etc/ansible/roles/docker ftp://ftp.icm.edu.pl/vol/rzm3/linux-fedora/linux/epel/7/x86_64/Packages/p/pigz-2.3.4-1.el7.x86_64.rpm && wget -N -P /etc/ansible/roles/docker https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm 配置docker安装脚本 vim /etc/ansible/roles/docker/docker

Ansible - pip not found

痴心易碎 提交于 2020-01-23 08:34:27
问题 I am getting this error: TASK [pip] ********************************************************************* failed: [default] (item=urllib3) => {"changed": false, "item": "urllib3", "msg": "Unable to find any of pip2, pip to use. pip needs to be installed."} Upon a suggestion I run following command: ansible default -a "which pip" I get an error: default | FAILED | rc=1 >> non-zero return code So I guess that means no pip installed. I tried installing pip using: ansible default -a "easy_install

How to inspect a json response from Ansible URI call

烂漫一生 提交于 2020-01-23 06:41:06
问题 I have a service call that returns system status in json format. I want to use the ansible URI module to make the call and then inspect the response to decide whether the system is up or down {"id":"20161024140306","version":"5.6.1","status":"UP"} This would be the json that is returned This is the ansible task that makes a call: - name: check sonar web is up uri: url: http://sonarhost:9000/sonar/api/system/status method: GET return_content: yes status_code: 200 body_format: json register: