diff --git a/install.yml b/install.yml deleted file mode 100644 index d4da75f..0000000 --- a/install.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -- name: Install system. - hosts: all - - roles: - - passwordless_connection - - prep - - disksetup - - configure - - tasks: - - name: Reboot system - reboot: diff --git a/configure.yml b/main.yml similarity index 66% rename from configure.yml rename to main.yml index 767a249..32773ff 100644 --- a/configure.yml +++ b/main.yml @@ -1,4 +1,17 @@ --- +- name: Install system. + hosts: all + + roles: + - passwordless_connection + - prep + - disksetup + - configure + + tasks: + - name: Reboot system + reboot: + - name: Configure system. hosts: all diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..66c7753 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,2 @@ +--- +- src: kewlfft.aur diff --git a/roles/configure/files/static.nmconnection b/roles/configure/files/static.nmconnection new file mode 100644 index 0000000..4247b7e --- /dev/null +++ b/roles/configure/files/static.nmconnection @@ -0,0 +1,13 @@ +[connection] +id=static +uuid=b47e7a95-b345-3725-ac60-1fd4ed350aab +type=ethernet +autoconnect-priority=999 +interface-name={{ net_interface }} + +[ipv4] +addresses={{ net_ip }}/24 +gateway={{ net_gateway }} +dns={{ net_dns }} +dns-search=localhost +method=manual diff --git a/roles/configure/tasks/main.yml b/roles/configure/tasks/main.yml index 84bd5f7..85f2f59 100644 --- a/roles/configure/tasks/main.yml +++ b/roles/configure/tasks/main.yml @@ -8,6 +8,30 @@ - fstrim.timer changed_when: true +- name: Get primary network interface. + set_fact: + net_interface: '{{ ansible_interfaces | reject("match", "^lo$") | first }}' + +- name: Set ip address. + set_fact: + net_ip: '{{ ansible_facts[net_interface]["ipv4"]["address"] }}' + +- name: Set gateway. + set_fact: + net_gateway: '{{ (ansible_facts[net_interface]["ipv4"]["network"] | split("."))[:3] | join(".") }}.1' + +- name: Set nameservers. + set_fact: + net_dns: '{{ ansible_facts["dns"]["nameservers"] | join(";") }};8.8.8.8;' + +- name: Create static ip config. + template: + src: files/static.nmconnection + dest: "{{ partitioning_root_mount_point }}/etc/NetworkManager/system-connections/static.nmconnection" + owner: root + group: root + mode: 0600 + - name: Make sure root's .ssh directory exists. file: state: directory