Use var for LXD password

This commit is contained in:
Khue Doan 2021-03-03 02:11:50 +07:00
parent b68d65f2ed
commit 3d6c0f44d0
6 changed files with 31 additions and 25 deletions

View File

@ -1,6 +1,6 @@
.POSIX:
default: init run
default: init provision
init:
python3 -m venv .venv \
@ -8,6 +8,10 @@ init:
&& pip3 install --upgrade pip \
&& pip3 install -r requirements.txt
run:
reset:
. .venv/bin/activate \
&& ansible-playbook --ask-become-pass --inventory hosts.ini playbook.yml
provision:
. .venv/bin/activate \
&& ansible-playbook --inventory hosts.ini playbook.yml --tags provision

View File

@ -2,10 +2,10 @@
hosts: all
gather_facts: no
vars_prompt:
- name: username
- name: os_username
prompt: Enter username for metal nodes
private: no
- name: password
- name: os_password
prompt: Enter password for metal nodes
roles:
- pxe-boot
@ -18,3 +18,5 @@
roles:
- snap
- lxd
tags:
- provision

View File

@ -27,22 +27,22 @@
creates: /var/snap/lxd/common/lxd/server.crt
when: inventory_hostname != groups['metal'][0]
- name: Add remote
command:
argv:
- lxc
- remote
- add
- vagrant
- "{{ hostvars[groups['metal'][0]]['ansible_host'] }}"
- --accept-certificate
- --password
- 1
# - name: Add remote
# command:
# argv:
# - lxc
# - remote
# - add
# - vagrant
# - "{{ hostvars[groups['metal'][0]]['ansible_host'] }}"
# - --accept-certificate
# - --password
# - 1
- name: Change default remote
command:
argv:
- lxc
- remote
- switch
- vagrant
# - name: Change default remote
# command:
# argv:
# - lxc
# - remote
# - switch
# - vagrant

View File

@ -1,6 +1,6 @@
config:
core.https_address: {{ hostvars[inventory_hostname]['ansible_host'] }}:8443
core.trust_password: "1"
core.trust_password: {{ lxd_password }}
networks:
- config:
bridge.mode: fan

View File

@ -5,4 +5,4 @@ cluster:
cluster_certificate: |
{{ hostvars[groups['metal'][0]]['server_cert']['content'] | b64decode | indent(width=4) }}
server_address: {{ hostvars[inventory_hostname]['ansible_host'] }}:8443
cluster_password: "1"
cluster_password: {{ lxd_password }}

View File

@ -30,7 +30,7 @@ services --enabled="chronyd"
timezone Asia/Ho_Chi_Minh --isUtc
# Create user
user --groups=wheel --name={{ username }} --password={{ password }}
user --groups=wheel --name={{ os_username }} --password={{ os_password }}
# Add SSH key
sshkey --username=root "{{ ssh_public_key }}"