ansible-playbook

Append list variable to another list in Ansible

你。 提交于 2020-06-24 05:44:09
问题 is it possible to append a variable list to a static list in ansible? I can define the whole list as a variable: my_list: - 1 - 2 - 3 and then use it in a playbook as something: {{my_list}} But I cannot seem to find how to do this (pseudo code): list_to_append: - 3 - 4 and then in the playbook: something: - 1 - 2 - {{append: list_to_append}} If that is in fact impossible, what would you suggest for my use case? I have a list of items in a parameter, but some of them are optional and should be

Ansible and Git Permission denied (publickey) at Git Clone

最后都变了- 提交于 2020-06-10 10:24:38
问题 I have a playbook where I am trying to clone from a private repo (GIT) to a server. I have setup ssh forwarding and when I ssh into the server and try to manually clone from the same repo, it successfully works. However, when I use ansible for the to clone the repo to the server, it fails with "Permission Denied Public Key". This is my playbook deploy.yml : --- - hosts: webservers remote_user: root tasks: - name: Setup Git repo git: repo={{ git_repo }} dest={{ app_dir }} accept_hostkey=yes

ansible: pass variable to a handler

假装没事ソ 提交于 2020-05-28 14:06:07
问题 I use an "eye" as a supervisor and on changes in templates have to runs something like this: eye load service.rb eye restart service.rb I want to define this as a single handler for all the apps and call it like eye reload appname And in a handler operate like this: - name: reload eye service command: eye load /path/{{ service }}.rb && eye restart {{ service }} But I can't find a way to pass variable to a handler. Is it possible? 回答1: handlers/main.yml: - name: restart my service shell: eye

ansible: pass variable to a handler

我与影子孤独终老i 提交于 2020-05-28 14:04:48
问题 I use an "eye" as a supervisor and on changes in templates have to runs something like this: eye load service.rb eye restart service.rb I want to define this as a single handler for all the apps and call it like eye reload appname And in a handler operate like this: - name: reload eye service command: eye load /path/{{ service }}.rb && eye restart {{ service }} But I can't find a way to pass variable to a handler. Is it possible? 回答1: handlers/main.yml: - name: restart my service shell: eye

Ansible create postgresql user with access to all tables?

僤鯓⒐⒋嵵緔 提交于 2020-05-26 10:25:39
问题 This should be very simple. I want to make an Ansible statement to create a Postgres user that has connection privileges to a specific database and select/insert/update/delete privileges to all tables within that specific database. I tried the following: - name: Create postgres user for my app become: yes become_user: postgres postgresql_user: db: "mydatabase" name: "myappuser" password: "supersecretpassword" priv: CONNECT/ALL:SELECT,INSERT,UPDATE,DELETE I get relation \"ALL\" does not exist

Difference between become and become_user in Ansible

我是研究僧i 提交于 2020-05-09 17:47:23
问题 Recently I started digging into Ansible and writing my own playbooks. However, I have a troubles with understanding difference between become and become_user . As I understand it become_user is something similar to su <username> , and become means something like sudo su or "perform all commands as a sudo user". But sometimes these two directives are mixed. Could you explain the correct meaning of them? 回答1: become_user defines the user which is being used for privilege escalation. become

Is it possible to have ansible use a “remote” playbook for git-based continuous deployment?

别等时光非礼了梦想. 提交于 2020-04-16 04:57:10
问题 I need to manage a few servers that run code that is currently being deployed there as a couple of git repositories. I would like to be able to store in the project's repository the parts (if not all) of the playbook that is relevant for the repository. For example, the list of package dependencies, virtualenv requirements, configuration templates. This will also allow those to change in a per branch/commit way. Meaning I can make sure that if I need to deploy a specific branch/commit,

Is it possible to have ansible use a “remote” playbook for git-based continuous deployment?

可紊 提交于 2020-04-16 04:56:59
问题 I need to manage a few servers that run code that is currently being deployed there as a couple of git repositories. I would like to be able to store in the project's repository the parts (if not all) of the playbook that is relevant for the repository. For example, the list of package dependencies, virtualenv requirements, configuration templates. This will also allow those to change in a per branch/commit way. Meaning I can make sure that if I need to deploy a specific branch/commit,

Ansible, with_subelements and skip_missing does not work

时光怂恿深爱的人放手 提交于 2020-04-12 06:53:26
问题 I have the following problem: A host_var defining my nginx sites (excerpt): nginx_sites: - server: name: site1 location1: config: name: "/" [...] - server: name: site2 location1: config: name: "/" [...] location2: config: name: "/secretspace" [...] htaccess: username: password: somepassword In this example I have 2 sites. The second one has two locations where the second one has a subelement named "htaccess". This is what I want to use in order to create an corresponding htaccess file. I

clone a specific branch from git through ansible playbook

时光怂恿深爱的人放手 提交于 2020-04-10 06:47:08
问题 I am using ansible to deploy my app. I am cloning the app from github using the following: - 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 I want to clone a specific branch from the repository. I read the documentation of ansible but couldn't find any option to clone a specific branch. It has an option to clone a version but not branch. 回答1: