Use sudo for role testing
There are 2 ways to realize the privilege escalation needed for the gate jobs. 1) Editing the playbooks (and hope to not forget to write the sudo/become lines for every role) 2) Editing the inventory and set the variable there. I'm taking the second approach with the minimum set of variables (become_method is sudo by default and become_user is root by default). Change-Id: I066ac778f7bf3d3f569791e30067bcab4e8eef6b Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
parent
eb9f3d858b
commit
9a5dab4ca5
@ -1,3 +1,3 @@
|
|||||||
[defaults]
|
[defaults]
|
||||||
roles_path = ../../
|
roles_path = ../../
|
||||||
|
remote_tmp = ../.ansible/tmp/
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
[all]
|
[all]
|
||||||
localhost ansible_connection=local
|
localhost ansible_connection=local ansible_become=True
|
||||||
|
@ -16,6 +16,18 @@
|
|||||||
- name: Playbook for role testing
|
- name: Playbook for role testing
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
connection: local
|
connection: local
|
||||||
|
pre_tasks:
|
||||||
|
- name: Ensure root ssh key
|
||||||
|
user:
|
||||||
|
name: "{{ ansible_env.USER | default('root') }}"
|
||||||
|
generate_ssh_key: "yes"
|
||||||
|
ssh_key_bits: 2048
|
||||||
|
ssh_key_file: ".ssh/id_rsa"
|
||||||
|
- name: get the calling users key
|
||||||
|
command: cat ~/.ssh/id_rsa.pub
|
||||||
|
register: key_get
|
||||||
|
- set_fact:
|
||||||
|
lxc_container_ssh_key: key_get.stdout
|
||||||
roles:
|
roles:
|
||||||
- role: "{{ rolename | basename }}"
|
- role: "{{ rolename | basename }}"
|
||||||
lxc_net_bridge: lxcbr0
|
lxc_net_bridge: lxcbr0
|
||||||
|
Loading…
Reference in New Issue
Block a user