ansible-playbook

How to get variables from ansible result

牧云@^-^@ 提交于 2020-02-01 04:53:26
问题 I have a shell script whose output is an echo of the following format <variable_1>;<variable_2>;<variable_3> etc I want to use these variables and run a mysql query to update a DB like so mysql -u<user> -p<password> -h<host> -e'insert into test_table values ("variable_1","variable_2","variable_3")' My ansible playbook looks like this. --- - hosts: infoServers sudo: yes gather_facts: no tasks: - name: gather info script: get_hostdata.sh register: result - name: print result local_action:

How to get variables from ansible result

落爺英雄遲暮 提交于 2020-02-01 04:52:36
问题 I have a shell script whose output is an echo of the following format <variable_1>;<variable_2>;<variable_3> etc I want to use these variables and run a mysql query to update a DB like so mysql -u<user> -p<password> -h<host> -e'insert into test_table values ("variable_1","variable_2","variable_3")' My ansible playbook looks like this. --- - hosts: infoServers sudo: yes gather_facts: no tasks: - name: gather info script: get_hostdata.sh register: result - name: print result local_action:

Ansible file doesn't exist for S3 but exists for copy

寵の児 提交于 2020-01-25 05:52:26
问题 I'm trying to migrate my config files from a folder on an ec2 instance to an s3 bucket. We use ansible to update changes to these config files every deploy and I'm having issues getting ansible to work with s3. Here's the old ansible section for updating the config files to ec2. - name: Install config files copy: src="{{core_repo}}/config/{{item.path}}" dest=/opt/company/config owner=user group=user mode=0644 directory_mode=0755 with_items: config_files tags: - deploy nothing crazy, just copy

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 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:

Best way to launch aws ec2 instances with ansible

倖福魔咒の 提交于 2020-01-19 04:46:37
问题 I'm trying to create an small webapp infrastructure with ansible on Amazon AWS and I want to do all the process: launch instance, configure services, etc. but I can't find a proper tool or module to deal with that from ansible. Mainly EC2 Launch. Thanks a lot. 回答1: This is the short answer of your question, if you want detail and fully automated role, please let me know. Thanks Prerequisite : Ansible Python boto library Set up the AWS access and secret keys in the environment settings (best

Install Rbenv using Ansible

情到浓时终转凉″ 提交于 2020-01-15 21:03:20
问题 I am trying to install Rbenv on my server using Ansible but getting this error: TASK: [rbenv | create temporary directory] * ** * ** * ** * ** * ** * **** fatal: [localhost] => Conditional expression must evaluate to True or False: is_failed($rbuild_present) FATAL: all hosts have already failed -- aborting My playbook is: --- - name: rbenv | update rbenv repo git: repo=git://github.com/sstephenson/rbenv.git dest=$rbenv_root version=v0.4.0 - name: rbenv | add rbenv to path file: path=/usr

Install Rbenv using Ansible

≯℡__Kan透↙ 提交于 2020-01-15 21:01:45
问题 I am trying to install Rbenv on my server using Ansible but getting this error: TASK: [rbenv | create temporary directory] * ** * ** * ** * ** * ** * **** fatal: [localhost] => Conditional expression must evaluate to True or False: is_failed($rbuild_present) FATAL: all hosts have already failed -- aborting My playbook is: --- - name: rbenv | update rbenv repo git: repo=git://github.com/sstephenson/rbenv.git dest=$rbenv_root version=v0.4.0 - name: rbenv | add rbenv to path file: path=/usr

Ansible: copying one unique file to each server in a group

牧云@^-^@ 提交于 2020-01-13 06:47:20
问题 I have a series of numbered files to be processed separately by each server. Each split file made using linux split and then xz compressed to save transfer time. split_001 split_002 split_003 ... split_030 How can I push these files out to a group of 30 servers with ansible? It does not matter which server gets which file so long as they each have a single unique file. I had used a bash file but I am looking for a better solution. Hopefully using ansible. Then I plan to run a shell command to

how to create Ansible playbook to obtain OS versions of the remote hosts?

风格不统一 提交于 2020-01-12 14:30:14
问题 I'm new to ansible. I have a requirement that requires me to pull OS version for of more than 450 linux severs hosted in AWS. AWS does not provide this feature - it rather suggests us to get it from puppet or chef. I created few simple playbooks which does not run --- - hosts: testmachine user: ec2-user sudo: yes tasks: - name: Update all packages to latest yum: name=* state=latest task: - name: obtain OS version shell: Redhat-release playbook should output a text file with hostname and OS