ansible-2.x

Ansible: how to solve “sudo: a password is required” error? [duplicate]

烂漫一生 提交于 2019-12-31 01:41:05
问题 This question already has an answer here : How can a user with SSH keys authentication have sudo powers in Ansible? [duplicate] (1 answer) Closed last year . I have 9 servers and i am trying to install a package using ansible, i am able to ssh into 5 of the servers using a password and other 4 does not ask any password while ssh'ng into them. However i have copied id_rsa.pub key to all the 9 servers. Now the ansible script is working fine for 5 server but w remaining 4 i am getting the

ansible get aws ebs volume id which already exist

半城伤御伤魂 提交于 2019-12-30 10:43:16
问题 I'm trying to get the aws volume id which already exist and attached to ec2 instance using ansible. I have a lookup task using the ec2_remote_facts module that get details of the ec2 instance including the volume id details the task: - name: lookup ec2 virtual machines ec2_remote_facts: aws_access_key: "{{aws_access_key}}" aws_secret_key: "{{aws_secret_key}}" region: "{{ec2_region}}" filters: instance-state-name: running "tag:Name": "{{server_name}}" "tag:Environment": "{{environment_type}}"

How to append the file using Ansible

我的未来我决定 提交于 2019-12-25 18:50:59
问题 I'm trying to append a file to the existing file. When I hit a specific url I get the updated data everytime. my requirement is to append the updated to the same file instead of creating a new file everytime. I'm using get_url module to get the file. but the file is not being updated. If I give the destination as new file then data is being copied to new file. 回答1: get_url doesn't appear to support that operation. You may need to retrieve the file and use the Assemble module to concatenate

How to append the file using Ansible

我的未来我决定 提交于 2019-12-25 18:50:05
问题 I'm trying to append a file to the existing file. When I hit a specific url I get the updated data everytime. my requirement is to append the updated to the same file instead of creating a new file everytime. I'm using get_url module to get the file. but the file is not being updated. If I give the destination as new file then data is being copied to new file. 回答1: get_url doesn't appear to support that operation. You may need to retrieve the file and use the Assemble module to concatenate

Ansible playbook: Requires sudo password [duplicate]

僤鯓⒐⒋嵵緔 提交于 2019-12-25 09:42:34
问题 This question already has an answer here : How can a user with SSH keys authentication have sudo powers in Ansible? [duplicate] (1 answer) Closed last year . I am currently working with ansible and I want to automate dumping of my Remote DB and import the dumped file to my local DB. Now, I encountered some problem for using sudo to switch user. playbook.yml --- - hosts: remoteserver vars: remote_db_name: dbname remote_filename: dbname_{{ lookup('pipe', 'date +%m-%d-%Y') }} local_folder: /home

Run ansible on specific hosts group

你说的曾经没有我的故事 提交于 2019-12-25 07:49:46
问题 I am trying to run ansible with the following command, ansible-playbook provision.yml -l webserver And my hosts file contains the following host groups, [webclient] 172.29.4.75 [webserver] 172.29.4.76 My provision.yml also contains 2 hosts as below, - hosts: webclient user: centos roles: - nginx - nvm - hosts: webserver user: centos roles: - tomcat My issue here is even thought I use "-l webserver" roles specified for webclient also runs in webclient hosts. How can I control it to run only

Unable to run script despite escalating privilege in Ansible

天大地大妈咪最大 提交于 2019-12-25 00:12:37
问题 Im trying to run a shell script on the host machine after copying it over there using ansible. The script has 777 permissions. Please read the below question as it gives the full scope of the actual issue that we are trying to deal with Set different ORACLE_HOME and PATH environment variable using Ansible - name: Run the Script [List] shell: "/tmp/sqlscript/sql_select.sh {{item}} >> /tmp/sqlscript/output.out" become: yes become_method: sudo become_user: oracle register: orh with_items: "{{

Ansible: Loop over a list of services and disable those from a list of unwanted services which are actually present

别说谁变了你拦得住时间么 提交于 2019-12-24 22:43:41
问题 I'm using Ansible to build a base image from a base installation of RHEL7.5 One of the things I want to do is to disable unwanted services. So I do this: - name: "| disable unwanted services" service: name: "{{ item }}" enabled: no state: stopped loop: "{{ disabled_services }}" when: disabled_services is defined Which works fine, testing on localhost; then I try it on a test build, and it errors because one of the services I'm trying to manage isn't even present. Say for example that disabled

ansible output printing unwanted things. how to format and display only specific data's

谁说我不能喝 提交于 2019-12-24 01:41:31
问题 I am using ansible 2.4 in centos, trying to run the below script in remote servers and getting the output. Here the problem is yum info output is showing with json format also. But i need to display only the output. How to remove the json format. --- - hosts: GeneralServer tasks: - name: Checking the service status shell: systemctl status {{ item }} with_items: - httpd - crond - postfix - sshd register: service - debug: var=service - name: Checking the package info shell : yum info {{ item }}

Search Dictionary Values in Ansible

白昼怎懂夜的黑 提交于 2019-12-24 01:03:53
问题 Having a dictionary like this: ossec_datacenter: atlanta: hostname: 'server1.fakedomain.net' ip: '192.168.12.170' port: '1515' miami: hostname: 'server2.fakedomain.net' ip: '192.168.20.31' port: '1514' dallas: hostname: 'server2.fakedomain.net' ip: '192.168.20.20' port: '1515' How would I search for all values in this dictionary in my when clause? I can access variables using ossec_datacenter[ossec_dc]['hostname'] But I want so search all values to make sure no matches are present. In other