2022-02-12 21:36:34 +00:00
|
|
|
---
|
|
|
|
- name: Disable Firewalld
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: firewalld.service
|
2023-04-24 02:14:38 +00:00
|
|
|
masked: true
|
|
|
|
enabled: false
|
|
|
|
force: true
|
2022-02-12 21:36:34 +00:00
|
|
|
state: stopped
|
|
|
|
tags: services
|
|
|
|
|
|
|
|
- name: Set SELinux to permissive
|
|
|
|
ansible.posix.selinux:
|
|
|
|
policy: targeted
|
|
|
|
state: disabled
|
|
|
|
tags: services
|
|
|
|
|
|
|
|
- name: Ensure packages are upgraded
|
|
|
|
ansible.builtin.dnf:
|
|
|
|
name: "*"
|
|
|
|
state: latest
|
|
|
|
tags: packages
|
|
|
|
|
2023-04-24 02:14:38 +00:00
|
|
|
- name: remove curl
|
|
|
|
ansible.builtin.dnf:
|
|
|
|
name: "curl"
|
|
|
|
state: absent
|
|
|
|
tags: packages
|
|
|
|
|
|
|
|
- name: add curl-minimal
|
|
|
|
ansible.builtin.dnf:
|
|
|
|
name: "curl-minimal"
|
|
|
|
state: latest
|
|
|
|
tags: packages
|
|
|
|
|
2022-02-12 21:36:34 +00:00
|
|
|
- name: Generate SSH key
|
|
|
|
block:
|
|
|
|
- name: Create ssh key for root
|
|
|
|
ansible.builtin.user:
|
|
|
|
name: root
|
2023-04-24 02:14:38 +00:00
|
|
|
generate_ssh_key: true
|
2022-02-12 21:36:34 +00:00
|
|
|
ssh_key_bits: 4096
|
|
|
|
ssh_key_file: .ssh/id_rsa
|
|
|
|
register: sshkey_register
|
|
|
|
tags: sshkey
|
|
|
|
|
|
|
|
- name: fetch_keys
|
|
|
|
tags: sshkey
|
|
|
|
fetch:
|
|
|
|
src: "~/.ssh/id_rsa.pub"
|
|
|
|
dest: "files/buffer/infra-id_rsa.pub"
|
2023-04-24 02:14:38 +00:00
|
|
|
flat: true
|
2022-02-12 21:36:34 +00:00
|
|
|
when: sshkey_register.ssh_public_key != ""
|
|
|
|
register: sshkey_fetch
|
|
|
|
|
|
|
|
when: tag.find("infra") != -1 and name == "infra1"
|
|
|
|
tags:
|
|
|
|
- infra
|
|
|
|
- sshkey
|
|
|
|
|
|
|
|
- name: Disable SSH Agent Forwarding
|
|
|
|
lineinfile:
|
|
|
|
dest: /etc/ssh/sshd_config
|
|
|
|
regexp: '^.*AllowAgentForwarding'
|
|
|
|
line: 'AllowAgentForwarding no'
|
|
|
|
tags: services
|
|
|
|
notify:
|
|
|
|
- restart_sshd
|
|
|
|
|
2023-04-24 02:14:38 +00:00
|
|
|
- name: Setup network
|
|
|
|
include_tasks: tasks/setup-network.yml
|
|
|
|
when: aio_install is undefined or not aio_install # don't run when AIO
|
2022-02-12 21:36:34 +00:00
|
|
|
args:
|
2023-04-24 02:14:38 +00:00
|
|
|
apply:
|
|
|
|
tags: interfaces
|
2022-02-12 21:36:34 +00:00
|
|
|
tags:
|
|
|
|
- interfaces
|
|
|
|
|
|
|
|
- name: Setup Infra Nodes
|
|
|
|
block:
|
|
|
|
- name: Install packages
|
|
|
|
ansible.builtin.dnf:
|
|
|
|
name:
|
|
|
|
- git-core
|
|
|
|
- wget
|
|
|
|
- chrony
|
|
|
|
- openssh-server
|
|
|
|
- sudo
|
|
|
|
state: latest
|
|
|
|
tags: packages
|
|
|
|
- name: Clone repository
|
|
|
|
ansible.builtin.git:
|
|
|
|
repo: https://review.opendev.org/openstack/openstack-ansible
|
|
|
|
dest: /opt/openstack-ansible
|
2023-04-24 02:14:38 +00:00
|
|
|
version: stable/zed
|
|
|
|
# version: 'b958c02eeed355484be12db736ed81a047f7d7c0'
|
|
|
|
# refspec: 'refs/changes/81/852181/2'
|
|
|
|
|
2022-02-12 21:36:34 +00:00
|
|
|
tags: repos
|
|
|
|
|
|
|
|
- name: Create ssh key for root
|
|
|
|
ansible.builtin.user:
|
|
|
|
name: root
|
2023-04-24 02:14:38 +00:00
|
|
|
generate_ssh_key: true
|
2022-02-12 21:36:34 +00:00
|
|
|
ssh_key_bits: 4096
|
|
|
|
ssh_key_file: .ssh/id_rsa
|
|
|
|
register: sshkey_register
|
|
|
|
tags: sshkey
|
|
|
|
|
|
|
|
- name: fetch_keys
|
|
|
|
tags: sshkey
|
|
|
|
fetch:
|
|
|
|
src: "~/.ssh/id_rsa.pub"
|
|
|
|
dest: "files/buffer/infra-id_rsa.pub"
|
2023-04-24 02:14:38 +00:00
|
|
|
flat: true
|
2022-02-12 21:36:34 +00:00
|
|
|
when: sshkey_register.ssh_public_key != ""
|
|
|
|
register: sshkey_fetch
|
|
|
|
when: tag.find("infra") != -1 or aio_install | default(false)
|
|
|
|
tags: infra
|
|
|
|
|
|
|
|
- name: Install packages on non-infra hosts
|
|
|
|
when: tag.find("infra") != -1 or aio_install | default(false)
|
|
|
|
ansible.builtin.dnf:
|
|
|
|
name:
|
|
|
|
- iputils
|
|
|
|
- lsof
|
|
|
|
- openssh-server
|
|
|
|
- sudo
|
|
|
|
- tcpdump
|
|
|
|
- python3
|
|
|
|
state: latest
|
|
|
|
|
|
|
|
- name: Copy key to others
|
|
|
|
ansible.posix.authorized_key:
|
|
|
|
user: root
|
|
|
|
state: present
|
|
|
|
key: "{{ lookup('file', 'files/buffer/infra-id_rsa.pub') }}"
|
2022-02-12 22:04:54 +00:00
|
|
|
when: tag.find("infra") == -1 and sshkey_fetch | default(false)
|
2022-02-12 21:36:34 +00:00
|
|
|
tags: sshkey
|
|
|
|
|
|
|
|
- name: Disable cloud init from future runs
|
|
|
|
file:
|
|
|
|
path: /etc/cloud/cloud-init.disabled
|
|
|
|
state: touch
|
|
|
|
mode: '0644'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
...
|